邪性 3 yıl önce
ebeveyn
işleme
b2318d76c5

+ 32 - 9
app.js

@@ -61,10 +61,22 @@ App({
     }
     user(this).then(res => login(this)).then(res => {
       this.globalData.codeSession = true;
-    }).catch(res => wx.lxd.Notify({
-      message: res,
-      icon: "warn-o"
-    }))
+    }).catch(res => {
+      if (wx.hasOwnProperty("lxd") && wx.lxd.hasOwnProprety("Notify")) {
+        wx.lxd.Notify({
+          message: res,
+          icon: "warn-o"
+        })
+      } else {
+        wx.showModal({
+          confirmText: '确认',
+          content: res,
+          showCancel: false,
+          title: '注意',
+        })
+      }
+    }
+    )
   },
   globalData: {
     // 定义tabber
@@ -104,11 +116,22 @@ App({
     hot: true,
     // 全局请求方法
     axios ({ url: _url = '', token: _token = true, method: _method = 'post', data: _data = {}, success: _success = () => { }, complete: _complete = () => { } }) {
-      let globalurl = "http://192.168.2.45:8887", error = (data) => {
-        wx.lxd.Notify({
-          message: data,
-          icon: "warn-o"
-        })
+      let globalurl = "http://192.168.2.45:8888", error = (data) => {
+        if (wx.hasOwnProprety("lxd") && wx.lxd.hasOwnProperty("Notify")) {
+          wx.lxd.Notify({
+            message: data,
+            icon: "warn-o"
+          })
+        } else {
+          wx.showModal({
+            confirmText: '确认',
+            content: data,
+            showCancel: false,
+            title: '注意',
+          })
+        }
+
+
       };
       globalurl = "https://lsr.zzly.vip";
       let header_token = {};

+ 4 - 5
pages/detail/detail.js

@@ -20,9 +20,9 @@ Page({
   },
   // 点击按钮事件
   onClickButton (e) {
-    let { type } = e.currentTarget.dataset;
+    let { type, status } = e.currentTarget.dataset;
     // 点击立即购买
-    if (type == "buy") {
+    if (type == "buy" && status != 0) {
       if (!token()) {
         wx.navigateTo({
           url: '/pages/sgin/sgin',
@@ -30,7 +30,6 @@ Page({
         return false
       }
       let { id, shopdetail } = this.data;
-      console.log(id)
       wx.navigateTo({
         url: `/pages/pay/pay?data=${JSON.stringify({ id, shopdetail })}`,
       })
@@ -44,9 +43,9 @@ Page({
       url: `/commodity/wx_commodity_detail/${id}/`,
       method: "get",
       success (res) {
-        let { amount, price, days, detail_images: detaillist, introduce: desc, main_image: img, name } = res.data.data;
+        let { amount, price, days, detail_images: detaillist, introduce: desc, main_image: img, name, status } = res.data.data;
         shopdetail = {
-          name, price, detaillist, desc, img, amount, days
+          name, price, detaillist, desc, img, amount, days, status
         };
         that.setData({
           shopdetail

+ 2 - 1
pages/detail/detail.wxml

@@ -33,7 +33,8 @@
     <!-- 功能条 -->
     <van-goods-action>
       <van-goods-action-icon data-type="share" icon="share-o" text="分享" bind:click="onClickIcon" />
-      <van-goods-action-button data-type="buy" text="立即购买" bind:click="onClickButton" />
+      <van-goods-action-button color="{{shopdetail.status==0 ? 'grey' : ''}}" data-status="{{shopdetail.status}}"
+        data-type="buy" text="{{shopdetail.status==0 ? '商品已下架': '立即购买'}}" bind:click="onClickButton" />
     </van-goods-action>
   </view>
 </l-container>

+ 13 - 4
pages/pay/pay.js

@@ -2,10 +2,6 @@
 const app = getApp();
 const { axios } = app.globalData;
 Page({
-
-  /**
-   * 页面的初始数据
-   */
   data: {
     loadding: false,//正在支付中 true
     disabled: false,//支付完毕 true
@@ -13,6 +9,8 @@ Page({
     paytype: "1",// 支付方式 单选
     balance: null,//余额
     result: [],//复选框
+    errmessage: '',//订单重复提示
+    show: false,//弹出框
   },
   // 请求余额
   Request () {
@@ -58,12 +56,17 @@ Page({
             appid, openid, notes, commodity, student, balance
           },
           success (res) {
+            console.log(res);
             that.setData({ loadding: true })
             let { data } = res.data;
             if (!data) {
               resolve({ type: 1, value: "支付成功" });
               return false;
             }
+            if (!!data.error_msg) {
+              that.setData({ show: true, errmessage: data.error_msg })
+              return false;
+            };
             wx.requestPayment({
               timeStamp: data.timeStamp,
               nonceStr: data.nonceStr,
@@ -95,6 +98,12 @@ Page({
       }
     );
   },
+  // 弹出框确定事件
+  confirmFunc () {
+    wx.redirectTo({
+      url: '/pages/order/order',
+    })
+  },
   // 挑选地址
   ChooseAddress () {
     wx.navigateTo({

+ 1 - 0
pages/pay/pay.json

@@ -1,5 +1,6 @@
 {
   "usingComponents": {
+    "van-dialog": "@vant/weapp/dialog/index",
     "van-submit-bar": "@vant/weapp/submit-bar/index",
     "van-cell": "@vant/weapp/cell/index",
     "van-tag": "@vant/weapp/tag/index",

+ 2 - 1
pages/pay/pay.wxml

@@ -64,4 +64,5 @@
     <van-submit-bar disabled="{{disabled}}" loading="{{loadding}}" price="{{ shopdetail.amount*100 }}"
       button-text="提交订单" bind:submit="onSubmit" />
   </view>
-</l-container>
+</l-container>
+<van-dialog title="提示" message-align="left" show="{{ show }}" message="{{errmessage}}" bind:confirm="confirmFunc" />

+ 1 - 1
project.private.config.json

@@ -27,7 +27,7 @@
         {
           "name": "支付页面",
           "pathName": "pages/pay/pay",
-          "query": "data={\"id\":3}",
+          "query": "data={\"id\":4,\"shopdetail\":{\"name\":\"2021年十月份餐费\",\"price\":\"20.00\",\"detaillist\":[\"https://lsr.zzly.vip/up/commodity_image/20211017171925772741.png\"],\"desc\":\"2021年十月份餐费,请在2021年10月6日中午12:00前完成缴费\",\"img\":\"https://lsr.zzly.vip/up/commodity_image/20210928084841234721.png\",\"amount\":\"340.00\",\"days\":17}}",
           "scene": null
         },
         {