Переглянути джерело

feat():增加服务开始和结束的按钮

geek 3 роки тому
батько
коміт
49d9f6fca1

+ 10 - 0
api/order.js

@@ -60,6 +60,16 @@ class order extends request {
         return res.data
     }
 
+    static async payOrder(orderIdList){
+        const res = await this.postRequest(`${this.BASE_URL}Order/xcxPay`,{orderIds:orderIdList})
+        return res.data
+    }
+
+    static async createMasterOrder(data) {
+        const res = await this.postRequest(`${this.BASE_URL}Order/payMasterOrder`,data)
+        return res.data
+    }
+
 }
 
 export default order

+ 6 - 6
api/product.js

@@ -6,17 +6,17 @@ class product extends request {
     //     console.log(res);
     // }
 
-    static async getProductList(productType=1,page = 1, pageSize = 10,type=1) {
-        const res = await this.getRequest(`${this.BASE_URL}Product/index?productTypeId=${productType}&page=${page}&pageSize=${pageSize}&type=${type}`)
+    static async getProductList(productType=1,page = 1, pageSize = 10,type=1,storeId=0) {
+        const res = await this.getRequest(`${this.BASE_URL}Product/index?productTypeId=${productType}&page=${page}&pageSize=${pageSize}&type=${type}&storeId=${storeId}`)
         return res.data;
     }
-    static async getProductById(id) {
-        const res = await this.getRequest(`${this.BASE_URL}Product/read?id=${id}`)
+    static async getProductById(id,shopId) {
+        const res = await this.getRequest(`${this.BASE_URL}Product/read?id=${id}&storeId=${shopId}`)
         return res.data;
     }
 
-    static async getProductTypeList(page = 1, pageSize = 10,type=1) {
-        const res = await this.getRequest(`${this.BASE_URL}Product/typeList?page=${page}&pageSize=${pageSize}&type=${type}`)
+    static async getProductTypeList(page = 1, pageSize = 10,type=1,storeId=0) {
+        const res = await this.getRequest(`${this.BASE_URL}Product/typeList?page=${page}&pageSize=${pageSize}&type=${type}&storeId=${storeId}`)
         return res.data;
     }
 

+ 6 - 0
api/user.js

@@ -20,9 +20,15 @@ class store extends request{
         const res = await this.postRequest(`${this.BASE_URL}User/editUser?name=${name}&birthday=${birthday}&avatar=${avatar}&sex=${sex}`)
         return res.data
     }
+
     static async getUserById(userId){
         const res = await this.getRequest(`${this.BASE_URL}User/read?id=${userId}`)
         return res.data
     }
+
+    static async recharge(data){
+        const res = await this.postRequest(`${this.BASE_URL}User/recharge`,data)
+        return res.data
+    }
 }
 export default store

+ 7 - 4
app.js

@@ -34,10 +34,10 @@ App({
     // if (this.userInfoReadyCallback) {
       // this.userInfoReadyCallback(res)
     // }
-    if(this.globalData.userInfo){
-      await self.wxLogin(this.globalData.userInfo);
-    }
-   
+    // if(this.globalData.userInfo){
+      await self.wxLogin({"type":"slince"});
+    // }
+
   },
   globalData: {
     userInfo: null,
@@ -61,6 +61,9 @@ App({
     wx.setStorageSync('token', info.userInfo.token)
     requestApi.HEAD.token = info.userInfo.token
     this.setUserInfo(info.userInfo)
+    if (this.checkLoginReadyCallback){
+      this.checkLoginReadyCallback(res);
+   }
     return info.userInfo
   },
   getPhoneNumber: async function(data){

+ 4 - 3
app.json

@@ -13,9 +13,10 @@
     "pages/shop/shop",
     "pages/prompt/prompt",
     "pages/food/food",
-    "pages/foodOrder/foodOrder"
-   
-  
+    "pages/foodOrder/foodOrder",
+    "pages/recharge/recharge",
+    "pages/payMoney/payMoney"
+
   ],
   "window":{
     "navigationBarBackgroundColor": "#fff",

BIN
images/no-pay.png


BIN
images/recharge.png


+ 8 - 5
pages/appointment/appointment.js

@@ -51,7 +51,7 @@ Page({
     let storeInfo = await storeApi.getStoreById(shopId);
     let address = storeInfo.info.address;
     let shopName = storeInfo.info.shopName;
-    let product = await productApi.getProductById(productId);
+    let product = await productApi.getProductById(productId,shopId);
     let productImg = product.info.productImg;
     let productName = product.info.productName;
     let price = product.info.currentPrice;
@@ -72,6 +72,7 @@ Page({
       staffsList,
       staffName,
       staffId,
+      productInfo:product.info
     })
     let userInfo = await app.getWxUserInfo();
     console.log(userInfo.name)
@@ -113,12 +114,14 @@ Page({
       return
     }
     let data = {
-      productId: self.data.productId,
+      productList: [{
+         productId: self.data.productId,
+         num: self.data.peopleNum,
+         staffId: 0,
+      }],
       storeId: self.data.shopId,
       appointmentTime: self.data.orderTime,
-      num: self.data.peopleNum,
       mobile: self.data.mobile,
-      staffId: self.data.staffId,
     }
     const rs = await orderApi.createOrder(data)
     let orderId = rs.orderId;
@@ -258,7 +261,7 @@ Page({
    * 生命周期函数--监听页面初次渲染完成
    */
   onReady: function () {
-
+    
   },
 
   /**

+ 2 - 2
pages/appointment/appointment.wxml

@@ -51,14 +51,14 @@
             </block>
         </mp-tabs>
     </view>
-    <view class="desc-title">选择技师</view>
+    <!-- <view class="desc-title">选择技师</view>
     <view class="section" style="width:93%;margin:15rpx auto">
         <picker bindchange="bindStaffChange" value="{{indexStaff}}" range-key="staffName" range="{{staffsList}}">
             <view class="staffName card">
                 当前选择:{{staffName}}
             </view>
         </picker>
-    </view>
+    </view> -->
     <view class="desc-title">联系人</view>
     <view class="product-mobile card f17">
         <view class="phone">

+ 72 - 130
pages/index/index.js

@@ -15,17 +15,7 @@ const app = getApp();
 
 Page({
   data: {
-
-    tabs: [{
-        title: '足浴'
-      },
-      {
-        title: '美甲'
-      },
-      {
-        title: '附加服务'
-      }
-    ],
+    tabs: [],
     activeTab: 0,
     tabHeight: 500,
     productList: [],
@@ -41,12 +31,8 @@ Page({
   onLoad: async function (options) {
     console.log(options)
     const self = this
-
     const tokenData = await commonApi.getToken();
-    console.log(tokenData)
-    console.log(requestApi.HEAD.token)
     if (tokenData.token && !requestApi.HEAD.token) {
-      console.log('设置token')
       wx.setStorageSync('token', tokenData.token)
       requestApi.HEAD.token = tokenData.token
     }
@@ -61,28 +47,6 @@ Page({
           } else {
             // 未授权
             console.log('未授权地理位置');
-            wx.getLocation({
-              type: 'wgs84',
-              async success(res) {
-                console.log(res)
-                const latitude = res.latitude
-                const longitude = res.longitude
-                wx.setStorageSync('lon', longitude)
-                wx.setStorageSync('lat', latitude)
-                const rs = await storeApi.getNearStore(latitude, longitude)
-                console.log(rs.info);
-                if (!rs.info.distance) {
-                  wx.showModal({
-                    title: '提示',
-                    content: '该门店打样了哦',
-                  })
-                }
-                self.setData({
-                  locationFlag: true,
-                  storeInfo: rs.info
-                })
-              }
-            })
           }
         }
       })
@@ -91,62 +55,68 @@ Page({
       self.setData({
         storeInfo: rs.info
       })
+      self.setData({
+        pageNo: [1, 1, 1,1,1,1,1],
+      })
+      await this.productTypeList()
+      await this.getProductList()
     }
 
     //根据机型设置现有的tab-content盒子高度
     let windowHeight = parseInt(wx.getSystemInfoSync().windowHeight) * parseInt(750 / wx.getSystemInfoSync().windowWidth) - 185
-
-    // await this.getProductList();
     self.setData({
       tabHeight: windowHeight
     })
-
-
   },
   onShow: async function (op) {
-    console.log(op)
-    console.log(this.data.isShow)
     const self = this
     if (self.data.chooseStoreId) {
+      console.log('选择了其他门店')
       const rs = await storeApi.getStoreById(self.data.chooseStoreId)
       self.setData({
         storeInfo: rs.info
       })
+      self.setData({
+        pageNo: [1, 1, 1],
+      })
+      await self.productTypeList()
+      await self.getProductList()
     }
     if (self.data.isShow == 1) {
       return
     }
     const tokenData = await commonApi.getToken();
     if (tokenData.token && !requestApi.HEAD.token) {
-      console.log('onshow设置了token')
       wx.setStorageSync('token', tokenData.token)
       requestApi.HEAD.token = tokenData.token
     }
-    // if (self.data.chooseStoreId) {
-    //   const rs = await storeApi.getStoreById(self.data.chooseStoreId)
-    //   self.setData({
-    //     storeInfo: rs.info,
-    //     chooseStoreId: 0
-    //   })
-    // }
-    await this.productTypeList()
-    await this.getProductList();
-    let tabs = this.data.tabs;
-    let activeTab = this.data.activeTab;
-    let defaultH  = '100%'
-    if (tabs[activeTab].list.length) {
-      defaultH = tabs[activeTab].list.length * 170
-    }
-    let productHeight = defaultH
+
     self.setData({
-      productHeight,
-      isShow:1
+      isShow: 1
     })
   },
 
   productTypeList: async function(){
     const self = this
-    const rs = await productApi.getProductTypeList(1,10)
+    let storeInfo = self.data.storeInfo;
+    console.log(storeInfo)
+    let storeId = 0
+    if (!storeInfo) {
+       storeId = 0
+    }else {
+      storeId = storeInfo.id
+    }
+    const rs = await productApi.getProductTypeList(1,10,1,storeId)
+    if (rs.count == 0) {
+      wx.showModal({
+        title: "提示",
+        content: "该门店暂无商品哦"
+      }).then(() => {
+        wx.navigateTo({
+          url: '/pages/shop/shop',
+        })
+      })
+    }
     self.setData({
       tabs: rs.list
     })
@@ -158,10 +128,18 @@ Page({
     let tabs = self.data.tabs;
     let pageSum = self.data.pageSum;
     let pageNo = self.data.pageNo;
-
-
-
-    let prolist = await productApi.getProductList(tabs[activeTab].id, pageNo[activeTab],10);
+    console.log(self.data.pageNo)
+    console.log(activeTab)
+    let storeInfo = self.data.storeInfo;
+    console.log(storeInfo)
+    let storeId = 1
+    if (!storeInfo) {
+       storeId = 1
+    }else {
+      storeId = storeInfo.id
+    }
+    console.log(storeInfo['id'])
+    let prolist = await productApi.getProductList(tabs[activeTab].id, pageNo[activeTab],10,1,storeInfo['id']);
     pageSum[activeTab] = prolist.pageCount;
     let list = prolist.list;
 
@@ -177,55 +155,15 @@ Page({
         tabs[activeTab].list = oldList;
       })
     }
-
-
+    let defaultH  = '100%'
+    if (tabs[activeTab].list.length) {
+      defaultH = tabs[activeTab].list.length * 170
+    }
+    let productHeight = defaultH
     self.setData({
       tabs,
-      pageSum
-    })
-  },
-  requestAll(url, data, header = {}, method) {
-    const _self = this
-    wx.showLoading()
-    return new Promise((resolve, reject) => {
-      wx.request({
-        url: url,
-        data: data,
-        header: header,
-        dataType: 'json',
-        method: method,
-        success: (res => {
-          wx.hideLoading()
-          if (res.data.code === 1) {
-            //200: 服务端业务处理正常结束
-            resolve(res.data)
-          } else {
-            if (res.data.code === 0) {
-              wx.showToast({
-                title: res.data.message,
-              })
-            }
-            if (res.data.code === 901) {
-              console.log(res.data)
-            }
-            //其它错误,提示用户错误信息
-            if (this._errorHandler != null) {
-              //如果有统一的异常处理,就先调用统一异常处理函数对异常进行处理
-              this._errorHandler(res)
-            }
-            reject(res)
-          }
-        }),
-        fail: (res => {
-          if (this._errorHandler != null) {
-            this._errorHandler(res)
-          }
-          wx.showToast({
-            title: '网络异常请,稍后再试~',
-          })
-          reject(res)
-        })
-      })
+      pageSum,
+      productHeight
     })
   },
   onTabClick(e) {
@@ -235,26 +173,23 @@ Page({
     if (tabs[index].list && tabs[index].list.length) {
       defaultH = tabs[index].list.length * 170
     }
-
-
     let productHeight = defaultH
-    console.log(productHeight)
-
-    console.log(tabs[index].list)
     this.setData({
       activeTab: index,
       productHeight
     })
   },
 
-  onChange(e) {
+  async onChange(e) {
     const index = e.detail.index
     let pageNo = this.data.pageNo;
     this.setData({
         activeTab: index,
         // pageNo: [1, 1, 1, 1]
       }),
-      this.getProductList()
+
+      await this.productTypeList()
+      await this.getProductList()
   },
   handleClick(e) {
 
@@ -273,15 +208,23 @@ Page({
         const speed = res.speed
         const accuracy = res.accuracy
         const rs = await storeApi.getNearStore(latitude, longitude)
-        console.log(rs.info);
         self.setData({
           locationFlag: true,
           storeInfo: rs.info
         })
+
+        await self.productTypeList()
+        await self.getProductList()
+        self.setData({
+          pageNo: [1, 1, 1],
+        })
       },
       fail(err) {
         console.log(err)
-
+        wx.showModal({
+          title: "提示",
+          content:"请授权获取位置功能",
+        })
       }
     })
   },
@@ -293,19 +236,12 @@ Page({
     let pageNo = this.data.pageNo;
     let pageSum = this.data.pageSum;
     pageNo[activeTab]++;
-    console.log('触底了')
     this.setData({
       pageNo
     })
-
     if (pageNo[activeTab] <= pageSum[activeTab]) {
-
-      console.log(pageNo)
-
       this.getProductList()
     }
-
-
   },
   /**
    * 页面相关事件处理函数--监听用户下拉动作
@@ -338,6 +274,12 @@ Page({
           locationFlag: true,
           storeInfo: rs.info
         })
+        if (!rs.info.distance) {
+          wx.showModal({
+            title: '提示',
+            content: '该门店打样了哦',
+          })
+        }
         var shopId = self.data.storeInfo.id;
         wx.navigateTo({
           url: '../product/product?shopId=' + shopId + '&productId=' + productId,

+ 1 - 1
pages/index/index.wxml

@@ -20,7 +20,7 @@
   </view>
   <!-- 产品信息 -->
   <view class="product">
-    <mp-tabs tabs="{{tabs}}" tab-class="tabItem" activeTab="{{activeTab}}" swiperClass="weui-tabs-swiper" bindtabclick="onTabClick" bindchange="onChange" activeClass="tab-bar-title__selected" tabUnderlineColor="#292E37" tabInactiveTextColor="#fff" tabActiveTextColor="#b1a384" tabBackgroundColor="#292E37" swiperHeight="1100">
+    <mp-tabs tabs="{{tabs}}" tab-class="tabItem" activeTab="{{activeTab}}" swiperClass="weui-tabs-swiper" bindtabclick="onTabClick" bindchange="onChange" activeClass="tab-bar-title__selected" tabUnderlineColor="#292E37" tabInactiveTextColor="#fff" tabActiveTextColor="#b1a384" tabBackgroundColor="#292E37" swiperHeight="1800">
       <block wx:for="{{tabs}}" wx:key="id">
         <view class="tab-content" data-set="{{item}}" slot="tab-content-{{index}}" bind:tap="handleClick" >
           <view class="shop-info">

+ 7 - 0
pages/index/index.wxss

@@ -65,6 +65,7 @@ Page {
   left: 50%;
   top: 28%;
   transform: translate(-50%);
+  margin-top: 42rpx;
 }
 
 .container{
@@ -83,6 +84,11 @@ Page {
   height: 100%;
 }
 
+.weui-tabs-bar__wrp {
+  position: fixed;
+  z-index: 2;
+}
+
 .container .product .weui-tabs .weui-tabs-bar__wrp .weui-tabs-bar__content {
   display: flex;
   height: 100rpx;
@@ -129,6 +135,7 @@ Page {
 .container .product .shop-info {
   width: 750rpx;
   height: 500rpx;
+  margin-top: 101rpx;
 }
 
 .container .product .shop-info > image {

+ 4 - 4
pages/order/order.wxml

@@ -4,11 +4,11 @@
     <view class="timer" wx:if="{{order.status==1}}">
         等待买家付款,剩余{{timer.minute}}分{{timer.second}}秒后自动关闭
     </view>
-    <view class="code-info" wx:if="{{order.status==2 && order.orderType !=3}}">
+    <view class="code-info" wx:if="{{(order.status == 2 || order.status == 5) && order.orderType !=3}}">
         <view class="code card">
             <canvas class="canvas-code" style="width:280rpx;height:280rpx" canvas-id="qrCode" />
             <view class="code-text f13 c-707070" wx:if="{{order.writeOffStatus==1}}">
-                进店请出示二维码进行核销
+                出示二维码进行核销
             </view>
 
             <view wx:if="{{order.writeOffStatus==2}}">
@@ -69,11 +69,11 @@
             <image src="../../images/icons/tel.png"></image>
             {{order.storeMobile}}
         </view>
-        <view class="f17 shop" wx:if="{{order.orderType !=3}}">技师</view>
+        <!-- <view class="f17 shop" wx:if="{{order.orderType !=3}}">技师</view>
         <view class="tel f14 c-707070 " wx:if="{{order.orderType !=3}}">
             <image src="../../images/icons/defult-user.png"></image>
             {{order.staffName}}
-        </view>
+        </view> -->
     </view>
     <view class="order-btn">
         <view class="delete-btn" bindtap="cancelOrder" wx:if="{{order.status==1}}">取消订单</view>

+ 1 - 1
pages/order/order.wxss

@@ -98,7 +98,7 @@
 }
 
 .container .shop-info {
-  height: 371rpx;
+  height: 271rpx;
   margin-top: 20rpx;
   padding: 20rpx 30rpx;
   background-color: #fff;

+ 134 - 0
pages/payMoney/payMoney.js

@@ -0,0 +1,134 @@
+// pages/payMoney/payMoney.js
+import utils from '../../utils/util'
+import orderApi from "../../api/order"
+const app = getApp()
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    show:false
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: async function (options) {
+    console.log(options)
+    const self = this
+    if(!app.globalData.userInfo){
+      await app.wxLogin({"type":"slince"})
+    }
+    const url = decodeURIComponent(options.q)
+    console.log(url)
+    const order = utils.getQueryString('https://llzlovesh.top?orderId=412,413')
+    console.log(order)
+    const info = await orderApi.payOrder(order.orderId)
+    self.setData({
+      info,
+      orderIds:order.orderId,
+      show:true
+    })
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+    
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  },
+  async moneyPay() {
+    const money = this.data.info.money
+    const total = this.data.info.total
+    if (money < total) {
+      wx.showToast({
+        title: '余额不足支付',
+      })
+    }
+    let data = {
+      orderIds:this.data.orderIds,
+      type: 'balance'
+    }
+    const rs = await orderApi.createMasterOrder(data)
+    wx.showModal({
+      title: '提示',
+      content: '支付成功',
+     }).then(()=> {
+       wx.switchTab({
+         url: '/pages/personorder/personorder',
+       })
+     })
+  },
+  async pay() {
+    let data = {
+      orderIds:this.data.orderIds,
+      type: 'xcx'
+    }
+    const rs = await orderApi.createMasterOrder(data)
+    wx.requestPayment({
+      timeStamp: rs.timeStamp,
+      nonceStr: rs.nonceStr,
+      package: rs.package,
+      signType: rs.signType,
+      paySign: rs.paySign,
+      success (res) {
+       wx.showModal({
+        title: '提示',
+        content: '支付成功',
+       }).then(()=> {
+         wx.switchTab({
+           url: '/pages/personorder/personorder',
+         })
+       })
+      },
+      fail (res) { 
+       wx.showToast({
+         title: '您取消了支付',
+       })
+      }
+    })
+  }
+})

+ 4 - 0
pages/payMoney/payMoney.json

@@ -0,0 +1,4 @@
+{
+  "usingComponents": {},
+  "navigationBarTitleText": "支付"
+}

+ 30 - 0
pages/payMoney/payMoney.wxml

@@ -0,0 +1,30 @@
+
+<block wx:if="{{show}}">
+<view class="order-info" wx:for="{{info.list}}">
+  <view class="order-item">
+    <view class="item-left">订单总价:</view> 
+    <view class="item-right">¥{{item.orderMoney}}</view>
+  </view>
+  <view class="order-item">
+    <view class="item-left">订单号:</view> 
+    <view class="item-right">{{item.orderSn}}</view>
+  </view>
+  <view class="order-item">
+    <view class="item-left">手机号:</view> 
+    <view class="item-right">{{item.mobile}}</view>
+  </view>
+</view>
+<view class="order-info">
+  <view class="order-item">
+    <view class="item-left">我的余额:</view> 
+    <view class="item-right">¥{{info.money}}</view>
+  </view>
+</view>
+<view class="order-info">
+  <view class="order-item pay">
+    <view class="total item-left">合计:¥{{info.total}}</view>
+    <view class="btn" bindtap="moneyPay">余额支付</view>
+    <view class="btn" bindtap="pay">微信支付</view>
+  </view>
+</view>
+</block>

+ 55 - 0
pages/payMoney/payMoney.wxss

@@ -0,0 +1,55 @@
+page {
+  background: #F8F8F8;
+  height: 100%;
+  width: 100%;
+}
+
+.order-info {
+  width: 700rpx;
+  margin-left: 25rpx;
+  margin-right: 25rpx;
+  background-color: #FFF;
+  margin-top: 25rpx;
+  border-radius: 15rpx;
+}
+
+.order-item {
+  display: flex;
+  flex-direction: row;
+  justify-content: space-between;
+  padding: 15rpx 10rpx 15rpx 10rpx;
+}
+
+.item-left {
+  font-size: 26rpx;
+  padding-left: 20rpx;
+}
+
+.item-right{
+  font-size: 26rpx;
+  padding-right: 20rpx;
+}
+
+.btn {
+  width: 150rpx;
+  height: 60rpx;
+  background-color: #BF2637;
+  justify-content: center;
+  align-items: center;
+  display: flex;
+  border-radius: 50rpx;
+  margin: 0 10rpx 0 10rpx;
+  color: #FFF;
+  font-size: 26rpx;
+}
+
+.pay {
+  /* justify-content: flex-end; */
+}
+
+.total {
+  display: flex;
+  align-items: center;
+  margin-right: 130rpx;
+  font-size: 26rpx;
+}

+ 9 - 2
pages/person/person.js

@@ -16,9 +16,10 @@ Page({
   onLoad: async function (options) {
     let userInfo = await app.getWxUserInfo()
     if (userInfo) {
+
       this.setData({
         userInfo: userInfo,
-        hasUserInfo: true,
+        hasUserInfo: userInfo.avatar.length > 1 ? true :false,
         hasMobile: userInfo.mobile ? true : false
       })
     }
@@ -36,9 +37,10 @@ Page({
   onShow: async function () {
     let userInfo = await app.getWxUserInfo()
     if (userInfo) {
+      console.log(userInfo)
       this.setData({
         userInfo: userInfo,
-        hasUserInfo: true,
+        hasUserInfo: userInfo.avatar.length > 1 ? true :false,
         hasMobile: userInfo.mobile ? true : false
       })
     }
@@ -136,4 +138,9 @@ Page({
       userInfo
     })
   },
+  gotoMoney() {
+    wx.navigateTo({
+      url: '/pages/recharge/recharge',
+    })
+  }
 })

+ 14 - 9
pages/person/person.wxml

@@ -1,17 +1,21 @@
 <!--pages/person/person.wxml-->
 <view class="container">
-    <view class="person card" wx:if="{{hasUserInfo}}" bindtap = "gotoPersonInfo">
+    <view class="person card" wx:if="{{hasUserInfo}}" >
         <view class="person-info">
-            <view class="user-name f18 c-202020" bindtap = "gotoPersonInfo">{{userInfo.name}}
+            <view class="user-name f18 c-202020" bindtap = "gotoPersonInfo">
+                {{userInfo.name}}
+                <!-- <open-data type="userNickName"></open-data> -->
                 <image class="next" src="../../images/icons/next.png" >
                 </image>
             </view>
             <view class="tel c-707070 fw300">{{userInfo.mobile}}</view>
+            <view> 余额:{{userInfo.money}}</view>
             <button open-type="getPhoneNumber" catchgetphonenumber="getMobile" class="login-btn" wx:if="{{!userInfo.mobile}}" >获取手机号</button>
         </view>
         <view class="head-img">
             <image class="" src="{{userInfo.avatar}}">
             </image>
+            <!-- <open-data type="userAvatarUrl"></open-data> -->
         </view>
     </view>
     <view wx:else class="user-login">
@@ -25,13 +29,8 @@
         </view>
         <view class="head-img">
             <image class="defult-user" src="../../images/icons/defult-user.png">
-
             </image>
-            
         </view>
-        
-
-
     </view>
     <view class="order" bindtap = "gotoOrder">
         <image class="icons" src="../../images/icons/order.png">
@@ -41,13 +40,19 @@
         <image class="next-gray" src="../../images/icons/next-gray.png">
         </image>
     </view>
-    <view class="assess" bindtap = "gotoComment">
+    <!-- <view class="assess" bindtap = "gotoComment">
         <image class="icons" src="../../images/icons/assess.png"></image>
         <view class="assess-text">我的点评
-
         </view>
         <image class="next-gray" src="../../images/icons/next-gray.png">
+        </image>
+    </view> -->
 
+    <view class="assess" bindtap = "gotoMoney">
+        <image class="icons" src="../../images/recharge.png" style="margin: 32rpx 0 0 7rpx;width: 97rpx;"></image>
+        <view class="assess-text">充值
+        </view>
+        <image class="next-gray" src="../../images/icons/next-gray.png">
         </image>
     </view>
 </view>

+ 125 - 0
pages/recharge/recharge.js

@@ -0,0 +1,125 @@
+// pages/joinFee/joinFee.js
+import userApi from '../../api/user'
+
+const app = getApp();
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: async function (options) {
+      
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: async function () {
+    
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+  bindMoney(e) {
+    let money = e.detail.value
+    this.setData({
+      money
+    })
+  },
+  async rechargeMoney(e) {
+    const self  = this
+    let money = e.currentTarget.dataset.money
+    console.log()
+    if (!money) {
+      money = self.data.money
+    } else {
+      self.setData({
+        money
+      })
+      money = self.data.money
+    }
+
+    if (!money) {
+      wx.showModal({
+        content: '请选择充值的金额',
+        title:'提示'
+      })
+      return
+    }
+    const confimObj = await wx.showModal({
+      content: `您确定要充值${money}元?`,
+      title:'提示'
+    })
+    //没同意
+    if (!confimObj.confirm) {
+      return
+    }
+
+    let data = {
+      recharge: money
+    }
+    const rs = await userApi.recharge(data)
+    let orderId = rs.orderId;
+    wx.requestPayment({
+      timeStamp: rs.timeStamp,
+      nonceStr: rs.nonceStr,
+      package: rs.package,
+      signType: rs.signType,
+      paySign: rs.paySign,
+      success (res) {
+       wx.showModal({
+        content: `充值成功`,
+        title:'提示'
+       }).then(() => {
+         wx.switchTab({
+           url: '/pages/person/person',
+         })
+       })
+      },
+      fail (res) { 
+       
+      }
+    })
+
+
+  }
+})

+ 3 - 0
pages/recharge/recharge.json

@@ -0,0 +1,3 @@
+{
+  "usingComponents": {}
+}

+ 34 - 0
pages/recharge/recharge.wxml

@@ -0,0 +1,34 @@
+<!-- <image class="add" src="../../img/jiahao.png"></image> -->
+<view class="pay" bindtap="rechargeMoney">充值</view>
+<view class="recharge-money">
+  <view class="money-num" type="primary" plain="true" data-money="50" bindtap="rechargeMoney">50元</view>
+  <view class="money-num" type="primary" plain="true" data-money="100" bindtap="rechargeMoney">100元</view>
+  <input class="money-num" type="number" maxlength="6" placeholder="自定义" bindinput="bindMoney" placeholder-style="color:#C0C0C0;text-align: center;">
+  <text style=" position: absolute; top: 152rpx; right: 40rpx; display: table-cell;white-space: nowrap;">元</text>
+  </input>
+</view>
+<view class="pay-record" wx:if="{{feeList.length > 0}}">支付记录</view>
+<view class="pay-list" wx:if="{{feeList.length > 0}}">
+  <block wx:for="{{feeList}}">
+    <view class="pay-info">
+        <view class="money-pos">
+          <image style="width:50rpx;height:50rpx" src="../../img/money.png"></image>
+        </view>
+        <view class="pay-desc">
+          <view class="pay-text">支付加盟意向金</view>
+          <view class="time">{{item.create_time}}</view>
+        </view>
+        <view class="money">
+          ¥{{item.money}}
+        </view>
+      </view>
+      <view class="pay-line"></view>
+  </block>
+    
+</view>
+<view wx:if="{{feeList.length <= 0}}" class="no-data">
+  暂无支付记录
+</view>
+<view wx:if="{{feeList.length <= -1}}">
+  <image class="no-pay" src="../../img/no-pay.png"></image>
+</view>

+ 135 - 0
pages/recharge/recharge.wxss

@@ -0,0 +1,135 @@
+/* pages/recharge/recharge.wxss */
+.jia {
+  width: 50rpx;
+  height: 50rpx;
+  border-radius: 50%;
+  background-color: #FFF;
+  position: relative;
+}
+
+.heng {
+  width: 40rpx;
+  color: #000;
+  height: 5rpx;
+  border-bottom: 5rpx solid #000;
+  position: relative;
+  top: 21rpx;
+  left: 1rpx;
+}
+
+.shu {
+  width: 5rpx;
+  color: #000;
+  height: 40rpx;
+  border-left: 5rpx solid #000;
+  margin-left: 17rpx;
+}
+
+.add  {
+  width: 50rpx;
+  height: 50rpx;
+  position: absolute;
+  z-index:999;
+  left: 221rpx;
+  top: 35rpx;
+}
+
+.pay {
+  width: 700rpx;
+  font-size: 30rpx;
+  font-weight: 500;
+  background-color: #07c160;
+  border-radius: 50rpx;
+  height: 80rpx;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  color: #FFF;
+  margin-left: 25rpx;
+  margin-top: 20rpx;
+}
+
+.pay-list {
+  display: flex;
+  flex-direction: column;
+}
+
+.pay-info  {
+  display: flex;
+  flex-direction: row;
+  margin-top: 20rpx;
+}
+
+
+.pay-line {
+  width: 700rpx;
+  margin-left: 25rpx;
+  margin-top: 10rpx;
+  border-bottom: 2rpx solid rgb(235, 234, 234);
+}
+
+.money-pos {
+  display: inline-flex;
+  padding-left: 18rpx;
+  padding-right: 10rpx;
+  padding-top: 20rpx;
+  width: 67rpx;
+}
+
+.pay-desc  {
+  display: flex;
+  flex-direction: column;
+  width: 482rpx;
+}
+
+.pay-text {
+  font-size: 30rpx;
+}
+.time {
+  font-size: 27rpx;
+  color: #777;
+  margin-top: 10rpx;
+}
+.money{
+  font-size: 34rpx;
+}
+
+.pay-record {
+  font-size: 25rpx;
+  color: #777;
+  margin-top: 20rpx;
+  margin-left: 10rpx;
+}
+
+.no-pay {
+  width: 500rpx;
+  height: 500rpx;
+  top: 50%;
+  position: relative;
+  left: 25%;
+}
+
+.no-data{
+  height: 750rpx;
+  line-height: 750rpx;
+  text-align: center;
+  color: #808080;
+}
+
+.recharge-money {
+  display: flex;
+  margin-top: 20rpx;
+}
+
+.money-num {
+  display: flex;
+  flex: 1;
+  justify-content: center;
+  height: 80rpx;
+  align-items: center;
+  border: 4rpx solid #07c160;
+  margin: 10rpx;
+  border-radius: 50rpx;
+  text-align: center;
+  color: #07c160;
+}

+ 12 - 0
project.private.config.json

@@ -59,6 +59,18 @@
           "pathName": "pages/order/order",
           "query": "id=272",
           "scene": null
+        },
+        {
+          "name": "充值",
+          "pathName": "pages/recharge/recharge",
+          "query": "",
+          "scene": null
+        },
+        {
+          "name": "pages/payMoney/payMoney",
+          "pathName": "pages/payMoney/payMoney",
+          "query": "",
+          "scene": null
         }
       ]
     }

+ 5 - 0
utils/date.js

@@ -7,8 +7,13 @@
    let closeMin = parseInt(closeTime.split(':')[1]);
    let openDate = new Date().setHours(openHour, openMin);
    let closeDate = new Date().setHours(closeHour, closeMin);
+   console.log(closeDate)
+   if (closeDate < openDate) {
+     closeDate += 3600 * 24 * 1000
+   }
    var dateList = [];
    while (closeDate >= openDate) {
+    console.log(hour)
      var hour = new Date(closeDate).getHours() < 10 ? '0' + new Date(closeDate).getHours() : new Date(closeDate).getHours();
      var minute = new Date(closeDate).getMinutes() < 30 ? '00' : '30';
      dateList.unshift({

+ 10 - 6
utils/util.js

@@ -13,12 +13,16 @@ const formatNumber = n => {
   n = n.toString()
   return n[1] ? n : '0' + n
 }
-const getQueryString = (name, url)=> {
-  var subIndex = url.substr(url.indexOf('?'));
-  var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
-  var r = subIndex.substr(1).match(reg);
-  if (r != null) return unescape(r[2]);
-  return null;
+
+
+const getQueryString = (url)=> {
+  var queryParts = url.slice(url.indexOf("?") + 1).split('&');
+    var params = queryParts.length > 0 ? {} : null;
+    queryParts.map(function (item) {
+      var a = item.split('=')
+      params[a[0]] = a[1]
+    })
+    return params
 } 
 
 module.exports = {