Explorar o código

feat: debug pay api & navigation index

wangyuan %!s(int64=2) %!d(string=hai) anos
pai
achega
c7f1137f0d
Modificáronse 9 ficheiros con 90 adicións e 48 borrados
  1. 8 2
      api/index.js
  2. 1 0
      app.json
  3. 6 1
      pages/appointment/appointment.js
  4. 34 18
      pages/buy/buy.js
  5. 20 15
      pages/buy/buy.wxml
  6. 11 10
      pages/buy/buy.wxss
  7. 5 0
      pages/index/index.js
  8. 1 1
      pages/index/index.wxml
  9. 4 1
      pages/my/my.js

+ 8 - 2
api/index.js

@@ -1,7 +1,13 @@
 
-// 首页 api 接口
+// 首页 以及 其他页面功能模块 api 接口
 import { wxRequest } from './request'
 
+// 首页
 const homePageURL = '/home/page'
 
-export const homePage =  (data) => wxRequest(homePageURL, data)
+// 套餐列表 支付页面
+const goodsListURL = '/goods/list'
+
+export const homePage =  (data) => wxRequest(homePageURL, data)
+
+export const goodsList =  (data) => wxRequest(goodsListURL, data)

+ 1 - 0
app.json

@@ -21,6 +21,7 @@
     "pages/myRecord/myRecord",
     "pages/scan/scan"
   ],
+  "requiredPrivateInfos": ["chooseAddress"],
   "usingComponents": {
     "van-icon": "@vant/weapp/icon/index",
     "van-overlay": "@vant/weapp/overlay/index",

+ 6 - 1
pages/appointment/appointment.js

@@ -269,7 +269,12 @@ Page({
     this.setData({
       hasAddress: true,
       appointmentSuccess: false,
-      timeActive: '1'
+      timeActive: '1',
+      addressId: '',
+      address: '',
+      province: '',
+      city: '',
+      county: '',
     })
   },
   handleCancel () {

+ 34 - 18
pages/buy/buy.js

@@ -1,39 +1,55 @@
 // pages/buy/buy.js
+import { goodsList } from '../../api/index'
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
-    payType: 1,
-  },
-
-  /**
-   * 生命周期函数--监听页面加载
-   */
-  onLoad(options) {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面初次渲染完成
-   */
-  onReady() {
-
+    activeIndex: -1,
+    goodsList: []
   },
 
   /**
    * 生命周期函数--监听页面显示
    */
   onShow() {
+    this.getGoodsList()
+  },
 
+  //获取套餐列表
+  getGoodsList () {
+    wx.showLoading({
+      title: '加载中...',
+      mask: true
+    })
+    goodsList({}).then(res => {
+      wx.hideLoading()
+      var response = res.data
+      response.map((item, index) => {
+        if (item.isRecommend) {
+          this.setData({
+            activeIndex: index
+          })
+        }
+      })
+      this.setData({
+        goodsList: response
+      })
+    }).catch(e => {
+      wx.hideLoading()
+      wx.showModal({
+        content: e,
+        confirmColor: '#333',
+        showCancel: false
+      })
+    })
   },
 
   handlePayType (e) {
-    var type = Number(e.currentTarget.dataset.type)
-    console.log(type);
+    var index = Number(e.currentTarget.dataset.index)
     this.setData({
-      payType: type
+      activeIndex: index
     })
   },
   // 调用微信支付

+ 20 - 15
pages/buy/buy.wxml

@@ -13,7 +13,7 @@
   <view class="chose-pay-type">
     <view class="title">选择检测套餐</view>
     <view class="pay-type">
-      <view class="pay-item one-time {{payType == 0 ? 'pay-item-active' : ''}}" data-type="0" bindtap="handlePayType">
+      <!-- <view class="pay-item one-time {{payType == 0 ? 'pay-item-active' : ''}}" data-type="0" bindtap="handlePayType">
         <view class="p-title">一次体验卡</view>
         <view class="p-prise">
           <text class="p-tag">¥</text>
@@ -22,21 +22,26 @@
         <view class="mark ittflex" wx:if="{{payType == 0}}">
           <van-icon name="success" color="#fff" />
         </view>
-      </view>
-      <view class="pay-item four-time {{payType == 1 ? 'pay-item-active' : ''}}" data-type="1" bindtap="handlePayType">
-        <view class="p-title-flex">
-          <view class="light-text ittflex">荐</view>
-          <text class="sub-title">4次套餐卡</text>
+      </view> -->
+      <block wx:for="{{goodsList}}" wx:key="index">
+        <view class="pay-item four-time {{index == activeIndex ? 'pay-item-active' : ''}}" data-index="{{index}}" bindtap="handlePayType">
+          <view class="p-title-flex">
+            <view class="light-text ittflex" wx:if="{{item.isRecommend}}">荐</view>
+            <text class="sub-title">{{item.goodsName}}</text>
+          </view>
+          <view class="p-prise">
+            <text class="p-tag">¥</text>
+            <text class="p-num">{{item.oncePrice}}</text>
+          </view>
+          <view class="tips">
+            <text wx:if="{{item.donateNumber > 0}}">加赠{{item.donateNumber}}次,</text>
+            <text>共{{item.useNumber}}次</text>
+          </view>
+          <view class="mark ittflex" wx:if="{{index == activeIndex}}">
+            <van-icon name="success" color="#fff" />
+          </view>
         </view>
-        <view class="p-prise">
-          <text class="p-tag">¥</text>
-          <text class="p-num">796</text>
-        </view>
-        <view class="tips">加赠4次,共8次</view>
-        <view class="mark ittflex" wx:if="{{payType == 1}}">
-          <van-icon name="success" color="#fff" />
-        </view>
-      </view>
+      </block>
     </view>
   </view>
   <view class="wxpay">

+ 11 - 10
pages/buy/buy.wxss

@@ -52,12 +52,17 @@
   font-weight: bold;
   color: #333333;
 }
-.pay-type {
+.chose-pay-type {
   width: 100%;
-  height: 302rpx;
+  min-height: 302rpx;
+}
+.pay-type {
+  width: 690rpx;
+  margin: 0 auto;
+  min-height: 302rpx;
   display: flex;
-  justify-content: center;
-  align-items: center;
+  justify-content: flex-start;
+  flex-wrap: wrap;
 }
 .pay-item {
   width: 280rpx;
@@ -66,6 +71,8 @@
   border-radius: 20rpx;
   border: 2rpx solid #DDDDDD;
   position: relative;
+  margin-left: 40rpx;
+  margin-top: 20rpx;
 }
 .pay-item-active {
   border: 2rpx solid #45A6B5;
@@ -113,12 +120,6 @@
   font-weight: bold;
   color: #333333;
 }
-.one-time {
-  margin-right: 20rpx;
-}
-.four-time {
-  margin-left: 20rpx;
-}
 .tips {
   font-size: 26rpx;
   font-weight: 400;

+ 5 - 0
pages/index/index.js

@@ -20,6 +20,7 @@ Page({
   onPullDownRefresh () {
     this.initIndexData(true)
   },
+  // 获取首页信息
   initIndexData (pullDownRefresh = false) {
     wx.showLoading({
       title: '加载中...',
@@ -47,6 +48,10 @@ Page({
       })
     })
   },
+  // 打开地图选择位置。
+  openMap () {
+    wx.chooseLocation()
+  },
   /**
    * 处理套餐 购买 or 预约  
    * useNumber: 0-购买 1-预约

+ 1 - 1
pages/index/index.wxml

@@ -3,7 +3,7 @@
   <view class="header">
     <view class="main-header">
       <view class="location">
-        <view class="location-info ittflex-jcs">
+        <view class="location-info ittflex-jcs" bindtap="openMap">
           <van-icon name="location" size="20px"/>
           <text class="l-text">{{locationStr}}</text>
         </view>

+ 4 - 1
pages/my/my.js

@@ -267,13 +267,16 @@ Page({
     var url = e.currentTarget.dataset.url
     this.authNavTo(url)
   },
+  handleAppoint () {
+    this.authNavTo('/pages/appointment/appointment')
+  },
   /**
    * 路由拦截
    * **/
   authNavTo (url) {
     if (itt.loginAuth()) {
       if (url.indexOf('/report') !== -1) {
-        app.globalData.selectedInex = '1'
+        app.globalData.selectedInex = 1
         wx.switchTab({
           url: url,
         })