sys 1 rok temu
rodzic
commit
fbf416686a
2 zmienionych plików z 21 dodań i 3 usunięć
  1. 2 0
      api/my.js
  2. 19 3
      pages/my/set/conversion.vue

+ 2 - 0
api/my.js

@@ -16,4 +16,6 @@ export const getDailyEarnings = (data) => request(goodsUrl + 'myself/getDailyEar
 //黑名单列表
 export const getBlackList = (data) => request(goodsUrl + 'myself/blacklist', 'get', data)
 export const delBlackItem = (data) => request(goodsUrl + 'myself/blacklist/'+data, 'delete', {})
+//兑换码
+export const exchangeCode = (data) => request(goodsUrl + 'myself/exchangeCode', 'post', data)
 

+ 19 - 3
pages/my/set/conversion.vue

@@ -16,6 +16,7 @@
 <script>
 import EnNav from "@/components/en-utils/en-nav/en-nav";
 import tools from "@/service/tools";
+import {exchangeCode} from "@/api/my";
 export default {
   components: {EnNav},
   data() {
@@ -23,6 +24,7 @@ export default {
       code:'',
       codeShake:false,
       isLogin:false,
+      isAjax:false
     }
   },
   watch:{
@@ -48,10 +50,24 @@ export default {
         tools.vibrate()
         return false
       }
-
-      uni.redirectTo({
-        'url':'/pages/my/set'
+      if(this.isAjax){
+        return ;
+      }
+      this.isAjax=true
+      exchangeCode({'code':this.code}).then((res)=>{
+        if(res.code===0){
+          tools.success('兑换成功')
+          setTimeout(()=>{
+            uni.redirectTo({
+              'url':'/pages/my/set'
+            })
+          },1500)
+        }else {
+          this.isAjax=false
+          tools.error(res.msg)
+        }
       })
+
     },
   }
 }