Kaynağa Gözat

feat: 流程处理

Damon 9 ay önce
ebeveyn
işleme
1f1e80b7d6
3 değiştirilmiş dosya ile 127 ekleme ve 39 silme
  1. 56 0
      src/api/public.js
  2. 26 31
      src/pages/public/remote.vue
  3. 45 8
      src/pages/public/uuid.vue

+ 56 - 0
src/api/public.js

@@ -0,0 +1,56 @@
+import request from '@/utils/request'
+const header = getApp().globalData.userInfo
+
+// 获取用户openId
+export function getUserInfo(data) {
+  return request({
+    url: `/wxMp/auth/getUserInfo`,
+    header,
+    method: 'get',
+    data
+  })
+}
+
+// 获取用户是否已经绑定
+export function deviceBindInfo(data) {
+  return request({
+    url: `/wxMp/remoteControl/deviceBindInfo`,
+    header,
+    method: 'post',
+    data
+  })
+}
+
+// 绑定用户
+export function deviceBind(data) {
+  return request({
+    url: `/wxMp/remoteControl/deviceBind`,
+    header,
+    method: 'post',
+    data
+  })
+}
+
+// 获取链接
+export function deviceUrlInfo(data) {
+  return request({
+    url: `/wxMp/remoteControl/deviceUrlInfo`,
+    header,
+    method: 'post',
+    data
+  })
+}
+
+
+// 新活动(联通流量免费赠送)
+// export function doNewActivity(data) {
+//   return request({
+//     // 设置请求头
+//     header: {
+//       'content-type': 'application/x-www-form-urlencoded'
+//     },
+//     url: `/order/4GActivity/doExchange`,
+//     method: 'post',
+//     data
+//   })
+// }

+ 26 - 31
src/pages/public/remote.vue

@@ -4,11 +4,10 @@
     <view class="search_container">
       <input
         type="text"
-        v-model="inputValue"
+        v-model="流量充值"
         class="search_public"
         confirm-type="done"
         disabled="true"
-        placeholder="流量充值"
       />
       <button class="search_btn" type="submit" @click="getSubmit1">前往</button>
     </view>
@@ -16,10 +15,9 @@
     <view class="search_container">
       <input
         type="text"
-        v-model="inputValue"
+        v-model="远程配网"
         class="search_public"
         disabled="true"
-        placeholder="远程配网"
       />
       <button class="search_btn" type="submit" @click="getSubmit2">绑定</button>
     </view>
@@ -27,46 +25,43 @@
 </template>
   
   <script>
-// import { detail, submit } from "@/api/activity.js";
+import { deviceUrlInfo } from "@/api/public.js";
 export default {
   data() {
     return {
-      uuid: "",
-      inputValue: "",
+      state: "",
+      openId: "",
+      flowUrl: "",
+      wifiUrl: "",
     };
   },
   onLoad(e) {
-    this.uuid = e.uuid;
+    this.state = e.state;
+    this.openId = e.openId;
   },
+
   methods: {
-    // http://ptt.radio1964.com/v1/device/get-wifi?UUId=AIrSMArT_210052355545
-    getSubmit1() {
-      if (this.inputValue.trim().length === 0) {
-        uni.showToast({
-          title: "UUID不能为空",
-          icon: "none",
-          mask: true,
-          duration: 2000,
-        });
-        return;
-      }
-      uni.navigateTo({
-        url: `/pages/pay/index?uuid=${this.uuid}`,
+    ///获取用户信息
+    deviceUrlInfo() {
+      deviceUrlInfo({
+        code: this.state,
+        code: this.openId,
+      }).then((res) => {
+        if (res.code === 0) {
+          this.flowUrl = res.data.flowUrl;
+          this.wifiUrl = res.data.wifiUrl;
+        }
       });
     },
 
+    getSubmit1() {
+      window.location.href =
+        `http://ptt.radio1964.com/v1/device/get-wifi?UUId=` + this.flowUrl;
+    },
+
     getSubmit2() {
-      if (this.inputValue.trim().length === 0) {
-        uni.showToast({
-          title: "UUID不能为空",
-          icon: "none",
-          mask: true,
-          duration: 2000,
-        });
-        return;
-      }
       window.location.href =
-        `http://ptt.radio1964.com/v1/device/get-wifi?UUId=` + this.uuid;
+        `http://ptt.radio1964.com/v1/device/get-wifi?UUId=` + this.wifiUrl;
     },
   },
 };

+ 45 - 8
src/pages/public/uuid.vue

@@ -22,18 +22,34 @@
 </template>
 
 <script>
-// import { detail, submit } from "@/api/activity.js";
+import { getUserInfo, deviceBindInfo, deviceBind } from "@/api/public.js";
 export default {
   data() {
     return {
-      uuid: "",
+      code: "",
+      state: "",
+      openId: "",
+      isBind: false,
       inputValue: "",
     };
   },
   onLoad(e) {
-    this.uuid = e.uuid;
+    this.code = e.code;
+    this.state = e.state;
+    this.getUserInfo();
   },
   methods: {
+    ///获取用户信息
+    getUserInfo() {
+      getUserInfo({
+        code: this.code,
+      }).then((res) => {
+        if (res.code === 0) {
+          this.openId = res.data.openId;
+        }
+      });
+    },
+
     // http://ptt.radio1964.com/v1/device/get-wifi?UUId=AIrSMArT_210052355545
     getSubmit() {
       if (this.inputValue.trim().length === 0) {
@@ -45,12 +61,33 @@ export default {
         });
         return;
       }
-      uni.navigateTo({
-        url: `/pages/public/remote?uuid=${this.uuid}`,
-      });
 
-      // window.location.href =
-      //   `http://ptt.radio1964.com/v1/device/get-wifi?UUId=` + this.uuid;
+      deviceBindInfo({
+        state: this.state,
+        openId: this.openId,
+      }).then((res) => {
+        if (res.code === 0) {
+          this.isBind = res.data.isBind;
+          ///已经绑定
+          if (this.isBind) {
+            uni.navigateTo({
+              url: `/pages/public/remote?state=${this.state}&openId=${this.openId}`,
+            });
+          } else {
+            deviceBind({
+              deviceMac: this.uuid,
+              state: this.state,
+              openId: this.openId,
+            }).then((res) => {
+              if (res.code === 0) {
+                uni.navigateTo({
+                  url: `/pages/public/remote?state=${this.state}&openId=${this.openId}`,
+                });
+              }
+            });
+          }
+        }
+      });
     },
   },
 };