lex-xin 3 months ago
parent
commit
ac42eb609f

+ 2 - 1
miniprogram/app.json

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

+ 5 - 0
miniprogram/pages/download/download.json

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

+ 62 - 0
miniprogram/pages/download/download.less

@@ -0,0 +1,62 @@
+/* pages/download/download.wxss */
+page {
+  height: 100vh;
+  display: flex;
+  flex-direction: column;
+  background: #F4F4F4;
+}
+
+.pageInfo {
+  height: 100%;
+  display: flex;
+  flex-direction: column;
+}
+.record-content {
+  display: flex;
+  flex-direction: column;
+  width: 100%;
+  flex: 1;
+  overflow-y: auto;
+}
+
+.record-list {
+  flex: 1;
+  overflow-y: scroll;
+  box-sizing: border-box;
+}
+.container {
+  background: url('https://oss.dayaedu.com/ktyq/1733231022871.png') no-repeat top center;
+  background-size: contain;
+  background-color: #FFFFFF;
+
+  .section {
+    display: flex;
+    align-items: center;
+    flex-direction: column;
+    padding: 414rpx 20rpx 190rpx;
+  }
+
+  .qrCodeImg  {
+    width: 296rpx;
+    height: 296rpx;
+  }
+
+  .func {
+    width: 100%;
+    margin: 23px 0 0;
+  }
+
+  .btnGroup {
+    position: fixed;
+    bottom: 0;
+    left: 0;
+    right: 0;
+    width: 100%;
+    padding: 16px 20px 30px;
+    background: linear-gradient( 180deg, rgba(255,255,255,0) 0%, #FFFFFF 50%, #FFFFFF 100%);
+    box-sizing: border-box;
+    .btnImg {
+      width: 100%;
+    }
+  }
+}

+ 91 - 0
miniprogram/pages/download/download.ts

@@ -0,0 +1,91 @@
+// pages/download/download.ts
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    isIOS: false,
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad() {
+    const wxDeviceInfo = wx.getDeviceInfo()
+    const isAndroid = wxDeviceInfo.platform === 'android'
+    this.setData({
+      isIOS: !isAndroid
+    })
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+  onDownload() {
+    wx.downloadFile({
+      url: 'https://oss.dayaedu.com/ktyq/1733277847031.png',
+      success: (res) => {
+        wx.saveImageToPhotosAlbum({
+          filePath: res.tempFilePath,
+          success: () => { 
+            wx.showToast({
+              title: '保存成功',
+              icon: 'success',
+            });
+          },
+          fail: () => {
+            wx.showToast({
+              title: '保存失败',
+              icon: 'none',
+            });
+          }
+        })
+      }
+    })
+  },
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})

+ 19 - 0
miniprogram/pages/download/download.wxml

@@ -0,0 +1,19 @@
+<!--pages/download/download.wxml-->
+<view class="pageInfo">
+  <navigation-bar title="下载音乐数字课堂"></navigation-bar>
+  <view class="record-content">
+    <scroll-view class="record-list" type="list" scroll-y>
+      <view class="container">
+        <view class="section">
+          <image src="https://oss.dayaedu.com/ktyq/1733226456374.png" class="qrCodeImg"></image>
+          <image wx:if="isIOS" mode="widthFix" src="https://oss.dayaedu.com/ktyq/1733230943390.png" class="func"></image>
+          <image wx:else mode="widthFix" src="https://oss.dayaedu.com/ktyq/1733233798354.png" class="func"></image>
+        </view>
+
+        <view class="btnGroup">
+          <image mode="widthFix" bind:tap="onDownload" src="https://oss.dayaedu.com/ktyq/1733230976760.png" class="btnImg"></image>
+        </view>
+      </view>
+    </scroll-view>
+  </view>
+</view>

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

@@ -199,9 +199,42 @@ page {
       letter-spacing: 10rpx;
     }
   } 
+  .qrCodeSection {
+    flex: 1;
+    width: 100%;
+    display: flex;
+    align-items: center;
+    flex-direction: column;
+  }
+  .qrcode-btn--section {
+    display: flex;
+    align-items: center;
+    padding-bottom: 22rpx;
+    button {
+      border-radius: 78rpx;
+      line-height: 26px;
+      padding: 5rpx 13rpx;
+      width: auto;
+      font-weight: 600;
+      font-size: 12px;
+      margin: 0 8rpx;
+      min-width: 148rpx;
+      box-sizing: border-box;
+    }
+    .submit {
+      background: linear-gradient( 90deg, #544F4A 0%, #302F2B 100%);
+      border-radius: 13px;
+      color: #FBEAC9;
+    }
+    .download {
+      border: 1px solid #C8C8C8;
+      background-color: #fff;
+      color: #333333;
+    }
+  }
   .qrcode-wrap {
     position: relative;
-    margin: 32rpx auto;
+    margin: 22rpx auto 22rpx;
     border: 2rpx solid #ECCEA0;
     padding: 6rpx;
     border-radius: 8rpx;

+ 36 - 2
miniprogram/pages/orders/order-result.ts

@@ -61,8 +61,6 @@ Page({
       this.setData({
         orderNo: options.orderNo,
         tabIdx: options.tabIdx
-      }, () => {
-        this.getDetail(this.onTimeout)
       });
     }
   },
@@ -70,6 +68,9 @@ Page({
     this.setData({
       serviceShow: true
     })
+    if(this.data.orderNo) {
+      this.getDetail(this.onTimeout)
+    }
   },
   onHide() {
     this.setData({
@@ -87,6 +88,7 @@ Page({
           tempGoods.push({
             ...item,
             shortUrl: item.activationCodeInfo.shortUrl,
+            code: item.activationCodeInfo.activationCode,
             originalPrice: this.formatPrice(item.paymentCashAmount, 'ALL'),
             typeName: this.formatPeriod(item.activationCodeInfo?.times || 1, item.activationCodeInfo.type)
           })
@@ -97,11 +99,13 @@ Page({
         } else if(result.refundStyle === 'OFFLINE') {
           refundStyleStr = '线下'
         }
+        const firstGoods = tempGoods[0]
         const goodsInfo = {
           orderNo: result.orderNo,
           createTime: result.createTime,
           wechatStatus: result.wechatStatus,
           goods: tempGoods,
+          code: firstGoods.code || '',
           refundOrderId: result.refundOrderId,
           refundTime: result.refundTime,
           refundAmount: this.formatPrice(result.refundAmount || 0, 'ALL'),
@@ -271,5 +275,35 @@ Page({
         wx.showToast({title: '复制失败,请稍后再试', icon: 'none'})
       }
     })
+  },
+  onActivation(e: { currentTarget: any  }) {
+    const code = e.currentTarget.dataset.code || ''
+    if(!code) {
+      wx.showToast({
+        title: '暂无法激活',
+        icon: 'none'
+      })
+      return
+    }
+    wx.navigateTo({
+      url: '../protocol/register?type=activation&code=' + code
+    })
+  },
+  onDownload() {
+    wx.saveImageToPhotosAlbum({
+      filePath: this.data.canvasImg,
+      success: () => { 
+        wx.showToast({
+          title: '保存成功',
+          icon: 'success',
+        });
+      },
+      fail: () => {
+        wx.showToast({
+          title: '保存失败',
+          icon: 'none',
+        });
+      }
+    })
   }
 })

+ 10 - 4
miniprogram/pages/orders/order-result.wxml

@@ -44,13 +44,19 @@
       <view class="qrcode-title" >{{ goodsInfo.wechatStatus == 'WAIT_USE' ? '请扫码激活' : '激活码已使用' }}</view>
       <view class="qrcode-line"></view>
       <view class="qrcode-section">
-        <view class="qrcode-text" wx:if="{{goodsInfo.wechatStatus == 'WAIT_USE'}}"><text>扫描下方二维码</text>激活</view>
+        <view class="qrcode-text" wx:if="{{goodsInfo.wechatStatus == 'WAIT_USE'}}"><text>扫描二维码</text>或<text>点击激活按钮</text>使用</view>
         <view class="qrcode-text used" wx:else>登录<text>「音乐数字课堂」</text>APP,开启AI学练之旅~</view>
         <view class="qrcode-block">
           <view class="left-text">{{goodsInfo.wechatStatus == 'WAIT_USE' ? '待使用' : '已使用'}}</view>
-          <view class="qrcode-wrap {{goodsInfo.wechatStatus == 'WAIT_USE' ? '' : 'used'}}">
-            <image src="{{canvasImg}}" mode="scaleToFill" class='my_draw_canvas' style="opacity: {{ goodsInfo.wechatStatus == 'PAID' ? 0.5 : 1 }};" show-menu-by-longpress="true"></image>
-            <view class="loader" wx:if="{{!canvasImg}}"></view>
+          <view class="qrCodeSection">
+            <view class="qrcode-wrap {{goodsInfo.wechatStatus == 'WAIT_USE' ? '' : 'used'}}">
+              <image src="{{canvasImg}}" mode="scaleToFill" class='my_draw_canvas' style="opacity: {{ goodsInfo.wechatStatus == 'PAID' ? 0.5 : 1 }};" show-menu-by-longpress="true"></image>
+              <view class="loader" wx:if="{{!canvasImg}}"></view>
+            </view>
+            <view class="qrcode-btn--section" wx:if="{{goodsInfo.wechatStatus == 'WAIT_USE'}}">
+              <button class="download" disabled="{{ !canvasImg ? true : false }}" bind:tap="onDownload">下载二维码</button>
+              <button class="submit" disabled="{{ !canvasImg ? true : false }}"  bind:tap="onActivation" data-code="{{ goodsInfo.code }}">立即激活</button>
+            </view>
           </view>
         </view>
       </view>

+ 22 - 9
miniprogram/pages/protocol/register.ts

@@ -23,18 +23,31 @@ Page({
         this.setData({
           src: app.globalData.baseUrl + '/classroom-app/#/preview-protocol?wx=3'
         })
+      } else if(options.type == 'activation') {
+        this.setData({
+          src: app.globalData.baseUrl + '/classroom-app/#/activationRegister?wx=wx_lite&code=' + options.code
+        })
+        // this.setData({
+        //   src: app.globalData.baseUrl + '/classroom-app/#/download?wx=wx_lite'
+        // })
       }
     }
-    // if(options.orderInfo) {
-    //   const orderInfo = JSON.parse(decodeURIComponent(options.orderInfo));
-    //   // console.log(orderInfo, app.globalData.baseUrl + `/classroom-app/?code=081xNSll2ff0xe4sb4ll2RxTRv0xNSlk#/payResult?paymentType=${orderInfo.paymentType}&pay_channel=${orderInfo.pay_channel}&wxAppId=${orderInfo.wxAppId}&body=${orderInfo.body}&price=${orderInfo.price}&orderNo=${orderInfo.orderNo}&userId=${orderInfo.userId}`)
-    //   const url = app.globalData.baseUrl + `/classroom-app/?code=0811HI0w3EfxT337iM1w3MifZf01HI0G#/payResultWechat?paymentType=${orderInfo.paymentType}&pay_channel=${orderInfo.pay_channel}&wxAppId=${orderInfo.wxAppId}&body=${orderInfo.body}&price=${orderInfo.price}&orderNo=${orderInfo.orderNo}&userId=${orderInfo.userId}`
-    //   this.setData({
-    //     src: url
-    //   }, () => {
-    //     console.log(this.data.src, 'src')
-    //   })
+
+    
+  },
+  onPostMessage(e: any) {
+    console.log(e, 'e------------------')
+    // https://oss.dayaedu.com/ktyq/1723428765364.apk
+    // const 
+    // const data = e.detail.data || []
+    // if(data.length <= 0) {
+    //   return
     // }
+    // data.forEach((item: any) => {
+    //   if(item.action === 'download') {
+        
+    //   }
+    // })
   },
 
   /**

+ 1 - 1
miniprogram/pages/protocol/register.wxml

@@ -1,4 +1,4 @@
 <!--pages/protocol/register.wxml-->
 <view class="container">
-    <web-view src="{{ src }}"></web-view>
+    <web-view src="{{ src }}" bindmessage="onPostMessage"></web-view>
 </view>