lex-xin 4 months ago
parent
commit
bc6c0786ab

+ 2 - 1
miniprogram/app.json

@@ -5,7 +5,8 @@
     "pages/orders/orders",
     "pages/login/login",
     "pages/orders/order-detail",
-    "pages/orders/order-result"
+    "pages/orders/order-result",
+    "pages/protocol/register"
   ],
   "window": {
     "navigationBarTextStyle": "black",

+ 2 - 2
miniprogram/pages/index/index.wxml

@@ -53,7 +53,7 @@
       <view class="goodsInfo">
         <text class="desc">已选:</text>
         <view class="goodsList">
-          <view wx:for="{{ list }}" wx:key="{{ index }}" class="goodsItem {{ item.id == selected.id ? 'selected' : '' }} {{ item.stockNum <= 0 ? 'nosale' : '' }}" bind:tap="onSelectGoods" data-id="{{ item.id }}">{{ item.typeName }}<image wx:if="{{ item.stockNum <= 0 }}" src="./images/nosale.png"></image></view>
+          <view wx:for="{{ list }}" wx:key="index" class="goodsItem {{ item.id == selected.id ? 'selected' : '' }} {{ item.stockNum <= 0 ? 'nosale' : '' }}" bind:tap="onSelectGoods" data-id="{{ item.id }}">{{ item.typeName }}<image wx:if="{{ item.stockNum <= 0 }}" src="./images/nosale.png"></image></view>
         </view>
       </view>
     </view>
@@ -102,7 +102,7 @@
         <view class="goodsInfo">
           <view class="desc">规格</view>
           <view class="goodsList">
-            <view wx:for="{{ list }}" wx:key="{{ index }}" class="goodsItem {{ item.id == selected.id ? 'selected' : '' }} {{ item.stockNum <= 0 ? 'nosale' : '' }}" bind:tap="onSelectGoods" data-id="{{ item.id }}">{{ item.typeName }}<image wx:if="{{ item.stockNum <= 0 }}" src="./images/nosale.png"></image></view>
+            <view wx:for="{{ list }}" wx:key="index" class="goodsItem {{ item.id == selected.id ? 'selected' : '' }} {{ item.stockNum <= 0 ? 'nosale' : '' }}" bind:tap="onSelectGoods" data-id="{{ item.id }}">{{ item.typeName }}<image wx:if="{{ item.stockNum <= 0 }}" src="./images/nosale.png"></image></view>
           </view>
         </view>
 

+ 6 - 0
miniprogram/pages/login/login.ts

@@ -87,6 +87,12 @@ Page({
       wx.hideLoading()
     }
   },
+  onProtocol(e: any) {
+    console.log(e)
+    wx.navigateTo({
+      url: '../protocol/register'
+    })
+  },
   /**
    * 生命周期函数--监听页面初次渲染完成
    */

+ 1 - 1
miniprogram/pages/login/login.wxml

@@ -12,7 +12,7 @@
     <view class="protocol-section">
       <image wx:if="{{isAgree}}" bind:tap="onAgree" src="./images/radio-active.png" class="radio"></image>
       <image wx:else bind:tap="onAgree" src="./images/radio-default.png" class="radio"></image>
-      <text bind:tap="onAgree">我已阅读并同意</text><text class="protocol">《小程序服务协议》</text><text class="protocol">《平台交易规则》</text><text class="protocol">《隐私政策》</text>
+      <text bind:tap="onAgree">我已阅读并同意</text><text class="protocol" bind:tap="onProtocol" data-type="register">《小程序服务协议》</text><text class="protocol">《平台交易规则》</text><text class="protocol" bind:tap="onProtocol" data-type="privacy">《隐私政策》</text>
     </view>
   </view>
 </view>

BIN
miniprogram/pages/orders/images/refound.png


+ 14 - 9
miniprogram/pages/orders/order-detail.ts

@@ -88,8 +88,8 @@ Page({
       console.log(data, 'data')
 
       if (data.code === 200) {
-        const { paymentConfig, paymentType } = data.data
-        this.onExecutePay(paymentConfig, paymentType)
+        const { paymentConfig, paymentType, orderNo } = data.data
+        this.onExecutePay(paymentConfig, paymentType, orderNo)
       } else {
         this.onPayError()
       }
@@ -97,7 +97,7 @@ Page({
       wx.hideLoading()
     }
   },
-  async onExecutePay( paymentConfig: any, paymentType: string) {
+  async onExecutePay( paymentConfig: any, paymentType: string, orderNo: string) {
     wx.login({
       success: async (wxres: any) => {
         const res = await api_executePayment({
@@ -105,11 +105,12 @@ Page({
           paymentChannel: 'wx_lite',
           paymentType,
           userId: app.globalData.userInfo?.id,
-          code: wxres.code
+          code: wxres.code,
+          wxMiniAppId: app.globalData.appId
         })
         wx.hideLoading()
         if(res.data.code === 200) {
-          this.onPay(paymentType, res.data.data.reqParams)
+          this.onPay(paymentType, res.data.data.reqParams, orderNo)
         } else {
           this.onPayError()
         }
@@ -119,7 +120,7 @@ Page({
       }
     })
   },
-  onPay(paymentType: string, paymentConfig: any) {
+  onPay(paymentType: string, paymentConfig: any, orderNo: string) {
     const isYeePay = paymentType.indexOf('yeepay') !== -1
     const prePayInfo = isYeePay ? JSON.parse(paymentConfig.prePayTn)
       : paymentConfig?.expend
@@ -133,10 +134,14 @@ Page({
       paySign: prePayInfo.paySign,
       signType: prePayInfo.signType ? prePayInfo.signType : 'MD5',
       success(resInfo) {
-        console.log('支付成功', resInfo)
-        wx.showToast({ title: '支付成功~', icon: 'success' });
+        console.log('支付成功', resInfo, {
+          orderNo, 
+          paymentConfig,
+          paymentType
+        })
+        wx.showToast({ title: '支付成功', icon: 'success' });
         wx.redirectTo({
-          url: '/pages/orders/order-result'
+          url: '/pages/orders/order-result?orderNo=' + orderNo
         })
       },
       fail(ressonInfo) {

+ 5 - 1
miniprogram/pages/orders/order-result.less

@@ -13,7 +13,6 @@ page {
   padding: 24rpx 32rpx;
   .status {
     display: flex;
-    padding-bottom: 24rpx;
     image {
       width: 48rpx;
       height: 48rpx;
@@ -27,6 +26,7 @@ page {
     }
   }
   .tips {
+    padding-top: 24rpx;
     font-size: 28rpx;
     color: #777777;
     line-height: 40rpx;
@@ -151,6 +151,10 @@ page {
       font-size: 28rpx;
       color: #777777;
       line-height: 40rpx;
+
+      &.red {
+        color: #FE2451;
+      }
     }
   }
 }

+ 24 - 29
miniprogram/pages/orders/order-result.ts

@@ -29,10 +29,16 @@ Page({
         logo: './images/wait.png',
         title: '等待使用',
         content: '请尽快扫描下方二维码进行激活'
+      },
+      REFUNDED: {
+        logo: './images/wait.png',
+        title: '退款成功',
+        content: '您的退款已成功处理,感谢您的理解和支持'
       }
     },
     goodsInfo: {} as any,
     orderNo: "" as string,
+    showCanvas: false, // 是否显示二维码
     canvasImg: "" as string
   },
 
@@ -41,6 +47,7 @@ Page({
    */
   onLoad(options: any) {
     if (options.orderNo) {
+      console.log(options, 'options')
       this.setData({
         orderNo: options.orderNo
       }, () => {
@@ -58,24 +65,36 @@ Page({
         goodsInfos.forEach((item: any) => {
           tempGoods.push({
             ...item,
+            shortUrl: item.activationCodeInfo.shortUrl,
             originalPrice: this.formatPrice(item.paymentCashAmount, 'ALL'),
             typeName: this.formatPeriod(item.goodsNum, item.activationCodeInfo.type)
           })
         })
+        const firstGoods = tempGoods[0]
+        let refundStyleStr = ''
+        if(firstGoods?.refundStyle === 'TURN_BACK') {
+          refundStyleStr = '原路返回'
+        } else if(firstGoods?.refundStyle === 'OFFLINE') {
+          refundStyleStr = '线下'
+        }
         const goodsInfo = {
           orderNo: result.orderNo,
           createTime: result.createTime,
           wechatStatus: result.wechatStatus,
-          goods: tempGoods
+          goods: tempGoods,
+          refundTime: firstGoods.refundTime,
+          refundAmount: firstGoods.refundAmount,
+          refundStyleStr
         }
         this.setData({
           goodsInfo,
           status: result.wechatStatus
         })
         if(result.wechatStatus != 'CLOSED') {
-          this.createQrCode(
-            'https://www.baidu.com/',
-            'canvasCode')
+          const firstGoods = tempGoods[0]
+          if(firstGoods?.shortUrl) {
+            this.createQrCode(firstGoods?.shortUrl, 'canvasCode')
+          }
         }
       }
     } catch (error) {
@@ -126,38 +145,13 @@ Page({
     }
     return size;
   },
-  setLogoSize() {
-    var size = {} as any;
-    try {
-      var res = wx.getSystemInfoSync();
-      var scale = 750 / 48; //不同屏幕下canvas的适配比例;设计稿是750宽
-      var width = res.windowWidth / scale;
-      var height = width; //canvas画布为正方形
-      size.w = width;
-      size.h = height;
-    } catch (e) {
-      // Do something when catch error
-      console.log("获取设备信息失败" + e);
-    }
-    return size;
-  },
   createQrCode(content: any, canvasId: any) {
     const size = this.setCanvasSize();
-    // const logoSize = this.setLogoSize();
     drawQrcode({
       width: size.w,
       height: size.h,
       canvasId: canvasId,
-      // ctx: wx.createCanvasContext('myQrcode'),
       text: content,
-      // v1.0.0+版本支持在二维码上绘制图片
-      // image: {
-      //   imageResource: "./images/codeLogo.png",
-      //   dx: (size.w - logoSize.w) / 2,
-      //   dy: (size.h - logoSize.h) / 2,
-      //   dWidth: logoSize.w,
-      //   dHeight: logoSize.h,
-      // },
       callback: () => {
         // 安卓机上不准确,生成的二维码无法扫描,加延时解决
         setTimeout(() => {
@@ -166,6 +160,7 @@ Page({
               canvasId: canvasId,
               success: (res) => {
                 this.setData({
+                  showCanvas: true,
                   canvasImg: res.tempFilePath,
                 });
               },

+ 20 - 5
miniprogram/pages/orders/order-result.wxml

@@ -8,11 +8,11 @@
         <image src="{{ statusList[status].logo }}"></image>
         <text>{{ statusList[status].title }}</text>
       </view>
-      <view class="tips">{{ statusList[status].content }}</view>
+      <view class="tips" wx:if="{{ statusList[status].content }}">{{ statusList[status].content }}</view>
     </view>
 
     <view class="order-content">
-      <view class="item-content" wx:for="{{ goodsInfo.goods }}" wx:key="{{ index }}">
+      <view class="item-content" wx:for="{{ goodsInfo.goods }}" wx:key="index">
         <image class='goods-icon' src="{{ item.goodsUrl }}" mode="" />
         <view class="goods-desc">
           <view class="goodsInfo">
@@ -25,12 +25,12 @@
           </view>
         </view>
       </view>
-      <view class="qrcode-section" wx:if="{{ goodsInfo.wechatStatus == 'SUCCESS' && goodsInfo.wechatStatus == 'WAIT_USE' }}">
+      <view class="qrcode-section" wx:if="{{ (goodsInfo.wechatStatus == 'SUCCESS' || goodsInfo.wechatStatus == 'WAIT_USE') && showCanvas }}">
         <view class="qrcode-wrap">
           <canvas class='my_draw_canvas' data-type="image" canvas-id='canvasCode' id="canvasCode"></canvas>
         </view>
-        <view class="qrcode-text used" wx:if="{{goodsInfo.wechatStatus == 'WAIT_USE'}}">二维码已使用</view>
-        <view class="qrcode-text" wx:else>请扫描二维码激活使用</view>
+        <view class="qrcode-text" wx:if="{{goodsInfo.wechatStatus == 'WAIT_USE'}}">请扫描二维码激活使用</view>
+        <view class="qrcode-text used" wx:else>二维码已使用</view>
       </view>
     </view>
 
@@ -44,6 +44,21 @@
         <view class="value">{{ goodsInfo.createTime }}</view>
       </view>
     </view>
+
+    <view class="order-time" wx:if="{{ goodsInfo.wechatStatus == 'REFUNDED' }}">
+      <view class="order-item">
+        <view class="title">退款时间</view>
+        <view class="value">{{ goodsInfo.refundTime }}</view>
+      </view>
+      <view class="order-item">
+        <view class="title">退款金额</view>
+        <view class="value">¥{{ goodsInfo.refundAmount }}</view>
+      </view>
+      <view class="order-item">
+        <view class="title">退款路径</view>
+        <view class="value red">{{ goodsInfo.refundStyleStr }}</view>
+      </view>
+    </view>
   </scroll-view>
 
   <view class="order-btn">

+ 5 - 6
miniprogram/pages/orders/orders.ts

@@ -1,5 +1,6 @@
 import { api_studentOrderPage } from "../../api/login";
-
+// 获取应用实例
+const app = getApp<IAppOption>()
 // pages/orders/orders.ts
 Page({
 
@@ -58,7 +59,6 @@ Page({
         }
       );
     }
-    
   },
   async getList() {
     wx.showLoading({
@@ -71,6 +71,7 @@ Page({
     try {
       // @ApiModelProperty("订单状态 WAIT_PAY:待付款,WAIT_USE:待使用,SUCCESS:已完成,CLOSE:已取消")
       const { data } = await api_studentOrderPage({
+        opneId: app.globalData.userInfo?.liteOpenid,
         page: currentPage,
         rows: this.data.rows,
         wechatOrderStatus: tabIdx == 0 ? "" : tabIdx == 1 ? "WAIT_PAY" : tabIdx == 2 ? "WAIT_USE" : tabIdx == 3 ? "SUCCESS" : tabIdx == 4 ? "CLOSED" : "",
@@ -81,7 +82,6 @@ Page({
           item.amount = this.formatPrice(item.paymentCashAmount, 'ALL')
           item.statusName = this.formatOrderStatus(item.wechatStatus)
           const studentPaymentOrderDetails = item.studentPaymentOrderDetails || [];
-          console.log(studentPaymentOrderDetails, 'studentPaymentOrderDetails')
           studentPaymentOrderDetails.forEach((student: any) => {
             student.originalPrice = this.formatPrice(student.paymentCashAmount, 'ALL');
             student.typeName = this.formatPeriod(student.goodsNum, student.activationCodeInfo?.type);
@@ -114,6 +114,7 @@ Page({
       WAIT_USE: '等待使用',
       SUCCESS: '交易完成',
       CLOSED: '交易取消',
+      REFUNDED: '退款成功'
     }
     return template[status]
   },
@@ -165,12 +166,10 @@ Page({
     }
   },
   onPay(e: any) {
-    console.log(e)
     const { currentTarget } = e
     const item = this.data.recordList.find((item: any) => item.id === e.currentTarget)
   },
-  onOne(e: any) {
-    console.log(e)
+  onOne() {
     wx.redirectTo({
       url: '../index/index',
     })

+ 5 - 5
miniprogram/pages/orders/orders.wxml

@@ -4,19 +4,19 @@
 
   <view class="record-content">
     <view class="record-tab">
-      <view wx:for="{{tabList}}" wx:key="item.id" class="{{item.id == tabIdx ? 'active' : ''}}" catch:tap="switchTab" data-idx="{{item.id}}">
+      <view wx:for="{{tabList}}" wx:key="id" class="{{item.id == tabIdx ? 'active' : ''}}" catch:tap="switchTab" data-idx="{{item.id}}">
         {{item.label}}
       </view>
     </view>
     <scroll-view class="record-list" type="list" scroll-y bindscrolltolower="loadMore">
       <block wx:if="{{ recordList.length }}">
         <view class="list-item-group">
-          <view class="list-item" wx:for="{{recordList}}" wx:key="{{index}}" data-orderno="{{item.orderNo}}" bind:tap="onDetail">
+          <view class="list-item" wx:for="{{recordList}}" wx:key="index" data-orderno="{{item.orderNo}}" bind:tap="onDetail">
             <view class="item-top">
               <view class="item-mid">订单号:{{ item.orderNo }}</view>
-              <text class="{{ item.status == 'WAIT_PAY' && item.status == 'WAIT_USE' ? 'red' : '' }}">{{ item.statusName }}</text>
+              <text class="{{ item.wechatStatus == 'WAIT_PAY' || item.wechatStatus == 'WAIT_USE' ? 'red' : '' }}">{{ item.statusName }}</text>
             </view>
-            <view class="item-content" wx:for="{{item.studentPaymentOrderDetails}}" wx:key="{{studentIndex}}">
+            <view class="item-content" wx:for="{{item.studentPaymentOrderDetails}}" wx:key="studentIndex">
               <image class='goods-icon' src="{{item.goodsUrl}}" mode="" />
               <view class="goods-desc">
                 <view class="goodsInfo">
@@ -33,7 +33,7 @@
               <view class="order-price">
                 订单金额:<text class="price">¥ {{item.amount}}</text>
               </view>
-              <button class="sure" type="primary" wx:if="{{ item.status == 'WAIT_PAY' && item.status == 'WAIT_USE' }}"  catch:tap="onPay" data-id="{{item.id}}">继续支付</button>
+              <button class="sure" type="primary" wx:if="{{ item.wechatStatus == 'WAIT_PAY' }}"  catch:tap="onPay" data-id="{{item.id}}">继续支付</button>
               <button type="primary" wx:else catch:tap="onOne" data-id="{{item.id}}">再来一单</button>
             </view>
           </view>

+ 5 - 0
miniprogram/pages/protocol/register.json

@@ -0,0 +1,5 @@
+{
+  "usingComponents": {
+    "navigation-bar": "/components/navigation-bar/navigation-bar"
+  }
+}

+ 1 - 0
miniprogram/pages/protocol/register.less

@@ -0,0 +1 @@
+/* pages/protocol/register.wxss */

+ 66 - 0
miniprogram/pages/protocol/register.ts

@@ -0,0 +1,66 @@
+// pages/protocol/register.ts
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})

+ 5 - 0
miniprogram/pages/protocol/register.wxml

@@ -0,0 +1,5 @@
+<!--pages/protocol/register.wxml-->
+<view class="container">
+  <navigation-bar title="协议" ></navigation-bar>
+  <web-view src="https://dev.kt.colexiu.com/classroom-app/#/privacy-protocol"></web-view>
+</view>