Browse Source

feat():修改bug

geek 4 years ago
parent
commit
cc215a30c9
3 changed files with 34 additions and 20 deletions
  1. 17 11
      pages/appointment/appointment.js
  2. 12 8
      pages/product/product.js
  3. 5 1
      pages/prompt/prompt.js

+ 17 - 11
pages/appointment/appointment.js

@@ -50,7 +50,7 @@ Page({
       this.setData({
         userInfo: userInfo,
         hasUserInfo: true,
-        hasMobile: userInfo.mobile ? true : false,
+        hasMobile: userInfo.mobile.length > 1 ? true : false,
         mobile: userInfo.mobile
       })
     }
@@ -66,19 +66,26 @@ Page({
       return
     }
     if (!self.data.orderTime){
-      // wx.showModal({
-      //   title: '提示',
-      //   content: '请选择预约时间',
-      //   showCancel:false,
-      // })
-      // return
+      wx.showModal({
+        title: '提示',
+        content: '请选择预约时间',
+        showCancel:false,
+      })
+      return
+    }
+
+    if (!self.data.mobile){
+      wx.showModal({
+        title: '提示',
+        content: '请输入手机号',
+        showCancel:false,
+      })
+      return
     }
-    self.data.orderTime = '19:00'
     let data = {
       productId: self.data.productId,
       storeId: self.data.shopId,
-      // appointmentTime: self.data.orderTime,
-      appointmentTime: '2021-02-27 19:00',
+      appointmentTime: self.data.orderTime,
       num: self.data.peopleNum,
       mobile: self.data.mobile
     }
@@ -91,7 +98,6 @@ Page({
       signType: rs.signType,
       paySign: rs.paySign,
       success (res) { 
-        console.log(res)
         wx.navigateTo({
           url: '../order/order?id=' + orderId,
         })

+ 12 - 8
pages/product/product.js

@@ -1,6 +1,7 @@
 // pages/productinfo/productinfo.js
 import productApi from '../../api/product'
 import commentsApi from '../../api/comments'
+const app = getApp()
 Page({
 
     /**
@@ -37,9 +38,6 @@ Page({
             commentsList: list,
             commentsNum: comments.count
         })
-
-
-
     },
     standardCommentsList: function (list) {
         list.forEach(function (item, i, array) {
@@ -107,14 +105,20 @@ Page({
             url: '../comments/comments?title=全部评论&commentstype=all&shopId=' + shopId + '&productId=' + productId,
         })
     },
-    gotoAppointment: function (e) {
+    gotoAppointment: async function (e) {
+        const self = this
+        console.log(this)
         var shopId = this.data.shopId;
         var productId = this.data.productId;
-        var productImg = this.data.product.productImg;
-        var productName = this.data.product.productName;
-        var price = this.data.product.currentPrice;
+        const isAuth = await app.isAuth()
+        if (!isAuth) {
+            wx.redirectTo({
+                url: '/pages/prompt/prompt?page=' + this.route+`&shopId=${shopId}&productId=${productId}`,
+            })
+            return
+        }
         wx.navigateTo({
-            url: '../appointment/appointment?' + 'shopId=' + shopId + '&productId=' + productId + '&productImg=' + productImg + '&productName=' + productName + '&price=' + price,
+            url: '../appointment/appointment?' + 'shopId=' + shopId + '&productId=' + productId,
         })
     }
 })

+ 5 - 1
pages/prompt/prompt.js

@@ -14,8 +14,12 @@ Page({
    */
   onLoad: async function (options) {
     console.log(options)
+    let page = options.page
+    if (options.page === 'pages/product/product') {
+      page = `${page}?shopId=${options.shopId}&productId=${options.productId}`
+    }
     this.setData({
-      fromPage: options.page
+      fromPage: page
     })
     let userInfo = await app.getWxUserInfo()
     console.log(userInfo);