Просмотр исходного кода

Merge branch 'master' of http://dev.hsfuel.com:3000/wei.chen/Fuelwx into feature/整合页面与接口

# Conflicts:
#	js/api.js
#	pages/login/login.js
#	project.private.config.json
Zhenghanjv 3 месяцев назад
Родитель
Сommit
80aa0f167a
4 измененных файлов с 117 добавлено и 3 удалено
  1. 6 2
      js/api.js
  2. 107 0
      pages/login/login.js
  3. 2 0
      pages/login/login.wxml
  4. 2 1
      project.config.json

+ 6 - 2
js/api.js

@@ -192,7 +192,10 @@ function request_NozzleAuthorization(data) {
 function request_CancelNozzleAuthorization(data) {
   return request('api/Nozzle/CancelNozzleAuthorization?trxid=' +data, "GET",data);
 }
-
+//退款
+function request_RefundTrx(data) {
+  return request('api/Transactions/RefundTrx', "POST",data);
+}
 
 export default {
   request_GetSiteInfo,
@@ -203,5 +206,6 @@ export default {
   request_CancelNozzleAuthorization,
   request_GetMiniProgramTransactionsUnpaidQuery,
   request_GetMiniProgramTransactionsUnpaidNozzle,
-  request_AddMiniprogramUser
+  request_AddMiniprogramUser,
+  request_RefundTrx
 }

+ 107 - 0
pages/login/login.js

@@ -66,6 +66,113 @@ Page({
 
   },
 
+  pay(){
+    api.request_wechatPay(23)
+    .then(res => {
+     wx.requestPayment({
+       timeStamp: res.data.data.unifiedOrderResult.timeStamp,
+       nonceStr: res.data.data.unifiedOrderResult.nonceStr,
+       package: res.data.data.unifiedOrderResult.package,
+       signType: res.data.data.unifiedOrderResult.signType,
+       paySign: res.data.data.unifiedOrderResult.paySign,
+       success: res => {
+         wx.hideLoading()
+         wx.showToast({
+           title: '支付成功!',
+         })
+         setTimeout(function () {
+           wx.switchTab({
+             url: '../index/index',
+           })
+         }, 2000)
+
+       },
+       fail: res => {
+         wx.hideLoading()
+         wx.showModal({
+           title: '支付失败',
+           content: res.errMsg + '请稍后再试',
+           showCancel: false,
+           success(res) {
+             if (res.confirm) {
+               wx.switchTab({
+                 url: '../home/home',
+               })
+             }
+           }
+         })
+       }
+     })
+    });
+  },
+  RefundTrx:function(e){
+    var RefundTrx = {
+      trxId : 31,
+      longitude :116.4074,
+      latitude:39.9042
+    };
+    api.request_RefundTrx(RefundTrx)
+    .then(res => {
+      debugger
+    });
+  },
+  handleGetPhoneNumber: function(e) {
+    if (e.detail.errMsg === 'getPhoneNumber:ok') {
+        // 用户同意授权,获取加密数据
+        const encryptedData = e.detail.encryptedData;
+        const iv = e.detail.iv;
+debugger
+        // 调用后端接口进行解密
+        wx.request({
+            url: 'https://your-backend-api-endpoint.com/decryptPhoneNumber', // 替换为你的后端API地址
+            method: 'POST',
+            data: {
+                encryptedData: encryptedData,
+                iv: iv,
+                sessionKey: 'your-session-key' // 替换为实际的session_key
+            },
+            success(res) {
+                console.log('解密后的手机号:', res.data);
+            },
+            fail(err) {
+                console.error('解密失败:', err);
+            }
+        });
+    } else {
+        console.log('用户拒绝授权');
+    }
+},
+  subMessage() {
+    wx.requestSubscribeMessage({
+      tmplIds: ['ldkKXfnHj-uKo6SBep08f_kaSjtxMOccJywHOEgxyPg'], // 最多支持3条
+      success(res) {
+        // 'accept'表示用户同意订阅该条id对应的模板消息
+        if (res['ldkKXfnHj-uKo6SBep08f_kaSjtxMOccJywHOEgxyPg'] === 'accept') {
+          // 用户同意订阅,调用云函数或服务器接口发送订阅消息
+          wx.cloud.callFunction({
+            name: 'sendSubscribeMessage',
+            data: {
+              templateId: '配置好的模板ID',
+              openid: 'o8pFb5fB9YROMFirFYrVNE3lr4ak',
+              data: {
+                thing1: {
+                  value: '活动名称'
+                },
+                // 其他参数...
+              }
+            },
+            success(res) {
+              console.log('订阅消息发送成功', res)
+            },   
+            fail(err) {
+              console.error('订阅消息发送失败', err)
+            }
+          })
+        }
+      }
+    })
+  },
+
   handleAuthLogin(e) {
     console.log('一键授权登录按钮被点击', e);
     wx.showLoading({

+ 2 - 0
pages/login/login.wxml

@@ -7,6 +7,8 @@
   <button class="auth-button" open-type="getPhoneNumber" style="width: 547rpx; height: 94rpx; display: block; box-sizing: border-box; left: 0rpx; top: 0rpx"  bindtap="handleAuthLogin" bindgetphonenumber="handleAuthLogin">一键授权登录</button>
   <view class="agreement">
     <button class="auth-button"   bindtap="pay">支付</button>
+    <button class="auth-button"   bindtap="RefundTrx">退款</button>
+    <button open-type="getPhoneNumber" bindgetphonenumber="handleGetPhoneNumber">获取手机号</button>
     <checkbox checked="{{true}}" disabled="{{true}}" />
     <text>我已阅读并同意</text>
     <text class="link">《用户协议》</text>

+ 2 - 1
project.config.json

@@ -24,5 +24,6 @@
     "tabIndent": "auto",
     "tabSize": 2
   },
-  "appid": "wxb198dafff060e651"
+  "appid": "wxb198dafff060e651",
+  "projectname": "fuelwx"
 }