Просмотр исходного кода

[ 商城 ] 282 商城 培训班报名优化

wangn 5 лет назад
Родитель
Сommit
77b9a15f02
2 измененных файлов с 32 добавлено и 18 удалено
  1. 29 18
      mallApp/src/pages/class/index.vue
  2. 3 0
      mallApp/src/pages/class/paySuccess.vue

+ 29 - 18
mallApp/src/pages/class/index.vue

@@ -33,7 +33,7 @@
           <text style="font-size: 40upx;padding-left: 10upx;">{{pageData.price}}</text>
           <text style="font-size: 40upx;padding-left: 10upx;">{{pageData.price}}</text>
         </text>
         </text>
       </text>
       </text>
-      <view class="confirm_btn" @click="confirm">确认</view>
+      <view class="confirm_btn" @click="confirm">提交</view>
     </view>
     </view>
   </view>
   </view>
 </template>
 </template>
@@ -63,31 +63,42 @@ export default{
   },
   },
   methods: {
   methods: {
     confirm(){
     confirm(){
-      if(this.dataList.form.nickname === ''){
-        this.$msg('请输入昵称')
+      let that = this
+      if(that.dataList.form.nickname === ''){
+        that.$msg('请输入昵称')
         return false
         return false
       }
       }
-      if(this.dataList.form.mobile === ''){
-        this.$msg('手机号不能为空')
+      if(that.dataList.form.mobile === ''){
+        that.$msg('手机号不能为空')
         return false
         return false
       }
       }
-       if (!/^1[34578]\d{9}$/.test(this.dataList.form.mobile)){
-           this.$msg('请输入正确的手机号')
+       if (!/^1[34578]\d{9}$/.test(that.dataList.form.mobile)){
+           that.$msg('请输入正确的手机号')
            return false
            return false
        }
        }
-         if(this.dataList.form.name === ''){
-        this.$msg('请输入姓名')
+         if(that.dataList.form.name === ''){
+        that.$msg('请输入姓名')
         return false
         return false
       }
       }
-      pxApplyAdd(this.dataList.form).then(res=>{
-        pxApplyWxPay({orderSn: res.data.orderSn}).then(res =>{
-          console.log(res)
-          weixinPay(res.data, this.successFn(), this.errorFn())
-        }).catch(err => { console.log(err, 'err') })
-        console.log(this.dataList.form.classId, 'classId')
-        console.log(res, 'res', pxApplyWxPay)
-      }).catch(err => {})
-      
+      uni.showModal({
+        title: '提示',
+        content: '这是一个模态弹窗',
+        success: function (res) {
+            if (res.confirm) {
+                console.log('用户点击确定', );
+                pxApplyAdd(that.dataList.form).then(res=>{
+                  pxApplyWxPay({orderSn: res.data.orderSn}).then(res =>{
+                    console.log(res)
+                    weixinPay(res.data, that.successFn, that.errorFn)
+                  }).catch(err => { console.log(err, 'err') })
+                  console.log(that.dataList.form.classId, 'classId')
+                  console.log(res, 'res', pxApplyWxPay)
+                }).catch(err => {})
+            } else if (res.cancel) {
+                console.log('用户点击取消');
+            }
+        }
+      });
     },
     },
     successFn() {
     successFn() {
       uni.navigateTo({
       uni.navigateTo({

+ 3 - 0
mallApp/src/pages/class/paySuccess.vue

@@ -19,6 +19,9 @@ export default {
   name: "AppResult",
   name: "AppResult",
   methods: {
   methods: {
     goClose () {
     goClose () {
+      uni.switchTab({
+        url: '/pages/home/course'
+      })
     }
     }
   }
   }
 };
 };