Commit d72dfac2 by 张立顺

feat:v4.8.0 功能开发完成

1 parent 824bc89b
// packagesPayment/pages/QRPayment/QRPayment.js
import api from '../../restapi'
const util = require('../../../utils/util.js')
const app = getApp()
Page({
/**
* 页面的初始数据
......@@ -7,36 +9,83 @@ Page({
data: {
KeyboardKeys: [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, '.'],
merchantId: '',
merchantName: '',
payMoney: '', // 支付金额
keyHidden: false,
unpaid: false,
unpaid: true,
showOrderInfo: false,
transactionReferenceNumber: '',
orderInfoList: [
{ label: '收款主体', info: '深圳市嘀加智慧云服务有限公司' },
{ label: '支付时间', info: '2022/07/06 16:53:21' }
]
// { name: 'merchantName', label: '商户名称', info: '' },
// { name: 'outTradeNo', label: '交易参考号', info: '' },
{ name: 'tradeNo', label: '流水号', info: '' },
{ name: 'payTime', label: '支付时间', info: '' }
],
// openID: 'oQ6Sh5cGirPd55Oc1J1oJSRpboFM',
outTradeNo: ''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// console.log('app', app.globalData.login())
console.log(options)
options = {
scene: 'sceneId%3D4'
}
// 根据
this.gteOpenId()
// this.successInfo()
// api.createWxPayOrderH5({ merchantId: '44184606', receivedMoney: 22 }, res => {
// // util.hideLoading()
// console.log(res)
// // console.log(JSON.parse(res.data))
// // let jsapiPayInfo = res.data ? JSON.parse(res.data) : {}
// // _this.wxPayment(jsapiPayInfo)
// })
// api.queryPayOrderStatus({ outTradeNo: '0120220709547257827237044224' }, res => {
// // util.hideLoading()
// console.log(res)
// // console.log(JSON.parse(res.data))
// // let jsapiPayInfo = res.data ? JSON.parse(res.data) : {}
// // _this.wxPayment(jsapiPayInfo)
// })
// options = {
// scene: 'sceneId%3D4'
// }
console.log(options.scene)
let id = decodeURIComponent(options.scene).split('=')[1]
console.log(id)
//获取门店信息
// api.qrCodeScene()
this.getMerthcantInfo(id)
// this.setData({
// merchantId: id
// })
},
gteOpenId: function () {
// debugger
// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
var self = this
// self.globalData.code = res.code
console.log('login', res)
// restapi.jsTestLogin(res.code, self.globalData.appId, function (response) {
api.authOpenId({ code: res.code, appId: app.globalData.appId }, function (response) {
console.log('response', response)
let { returnCode, data } = response
if (returnCode == 0) {
self.setData({
openId: data.openId
})
}
})
}
})
},
// 获取付款门店信息
getMerthcantInfo(id) {
api.qrCodeScene(
......@@ -54,6 +103,9 @@ Page({
const [key, val] = item.split('=')
op[key] = val
})
this.setData({
...op
})
//util.showLoading('加载中...')
console.log(op)
// this.getInfo(op)
......@@ -103,22 +155,43 @@ Page({
// 支付
handlePay() {
let _this = this
const { payMoney } = this.data
const { payMoney, merchantId, openId } = this.data
if (payMoney === '' || payMoney == '0' || payMoney == '0.0' || payMoney == '0.00') return
// this.wxPayment(payMoney)
console.log(Number(payMoney), '付款')
let params = {
merchantId,
openId,
receivedMoney: payMoney * 100
}
util.showLoading('加载中...')
// 调用支付接口生成对应的微信支付参数
api.queryPayOrderStatus(params, res => {
// util.hideLoading()
api.createWxPayOrderH5(params, res => {
util.hideLoading()
console.log(res)
let { returnCode, data } = res
if (returnCode == 0) {
let jsapiPayInfo = data.jsapiPayInfo ? JSON.parse(data.jsapiPayInfo) : {}
// 保存参考交易号在支付成功时调用
this.setData({
outTradeNo: data.outTradeNo
})
_this.wxPayment(jsapiPayInfo)
}
// console.log(JSON.parse(res.data))
let jsapiPayInfo = res.data ? JSON.parse(res.data) : {}
_this.wxPayment(jsapiPayInfo)
})
// api.queryPayOrderStatus(params, res => {
// // util.hideLoading()
// console.log(res)
// // console.log(JSON.parse(res.data))
// let jsapiPayInfo = res.data ? JSON.parse(res.data) : {}
// _this.wxPayment(jsapiPayInfo)
// })
},
// 调用微信支付
wxPayment(jsapiPayInfo) {
wxPayment(row) {
let _this = this
// if (this.data.ajaxing) {
// return false
......@@ -134,17 +207,45 @@ Page({
signType: 'MD5',
success: function (res) {
console.log(res)
wx.redirectTo({
url: '/packagePersonal/pages/boutiqueList/boutiqueList'
})
// 查询订单信息
util.showLoading('加载中...')
_this.successInfo()
},
fail: function (error) {
wx.switchTab({
url: '/pages/tab/index/index'
wx.showToast({
title: '支付失败',
icon: 'fail',
duration: 2000
})
}
})
},
// 支付成功获取订单回调信息
successInfo() {}
successInfo() {
let { outTradeNo, orderInfoList, showOrderInfo } = this.data
api.queryPayOrderStatus(
{ outTradeNo },
res => {
util.hideLoading()
console.log(res)
let { data, returnCode } = res
if (returnCode == 0) {
data &&
orderInfoList.forEach(element => {
element['info'] = data[element]
})
this.setData({
unpaid: false,
showOrderInfo: data ? true : false,
orderInfoList
})
}
// let { returnCode, data } = res
},
rej => {
console.log(rej)
util.hideLoading()
}
)
}
})
......@@ -7,7 +7,7 @@
<cover-image class="shopIcon" src="../../../images/shopIcon.png" />
<view class="company">
<view class="company-name">深圳市嘀加智慧云服务有限公司</view>
<view class="company-yqd">D+成都澳海园区店</view>
<view class="company-yqd">{{merchantName}}</view>
</view>
<!-- 付款给企业 -->
<!-- <view class="company-name">(深圳****公司)</view> -->
......@@ -57,13 +57,29 @@
<view wx:if="{{!unpaid}}">
<!-- <view>支付成功</view> -->
<view class="success-Container">
<view class="amountOfMoney">¥300.67</view>
<view class="amountOfMoney">¥ {{payMoney}}</view>
<view class="success-tips">
<cover-image class="successIcon" src="../../../images/successIcon.png" />
支付成功
</view>
<view class="line" />
<block wx:for="{{orderInfoList}}" wx:for-item="item" wx:key="index">
<view class="orderInfo">
<view class="label">收款主体</view>
<view class="info">深圳市嘀加智慧云服务有限公司</view>
</view>
<view class="orderInfo">
<view class="label">商户名称</view>
<view class="info">{{merchantName}}</view>
</view>
<view class="orderInfo">
<view class="label">交易参考号</view>
<view class="info">{{outTradeNo}}</view>
</view>
<block
wx:if="{{showOrderInfo}}"
wx:for="{{orderInfoList}}"
wx:for-item="item"
wx:key="index">
<view class="orderInfo">
<view class="label">{{item.label}}</view>
<view class="info">{{item.info}}</view>
......
......@@ -13,10 +13,51 @@ module.exports = {
restapi.req('/web-dj-weapp/home/qrCodeScene/getSceneById', qrcodeScene, {}, 'GET', 'json', 'text', success, fail)
},
/** 查询支付结果 */
queryPayOrderStatus: function (params) {
queryPayOrderStatus: function (params, success, fail) {
restapi.req(
'/web-dj-weapp/smartcarlife/payOrder/queryPayOrderStatus',
'/web-dj-weapp/smartcarlife/goodsOrder/queryPayOrderStatus',
params,
// {
// 'content-type': 'application/x-www-form-urlencoded'
// },
{
'content-type': 'application/json'
},
'POST',
'json',
'text',
success,
fail
)
},
/** 发起微信支付 */
createWxPayOrderH5: function (params, success, fail) {
restapi.req(
'/web-dj-weapp/smartcarlife/goodsOrder/createWxPayOrderH5',
params,
// {
// 'content-type': 'application/x-www-form-urlencoded'
// },
{
'content-type': 'application/json'
},
'POST',
'json',
'text',
success,
fail
)
},
/**
* 授权登录
* wechatAuthSetting:微信授权信息
*/
authOpenId: function (params, success, fail) {
restapi.req(
'/web-dj-weapp/jscode/getOpenId',
// JSON.stringify(code),
params,
{
'content-type': 'application/x-www-form-urlencoded'
},
......
......@@ -276,7 +276,7 @@
{
"name": "二维码进入",
"pathName": "packagesPayment/pages/QRPayment/QRPayment",
"query": "sence=merchantId%3D111",
"query": "scene=sceneId%3D4",
"scene": null,
"launchMode": "default"
}
......
// env:dev
// const domain = 'https://dj.dev.glsx.com.cn';
// env:dev 现在用上面的
// const domain = 'http://192.168.3.181:9182'
const domain = 'https://dj.dev.glsx.com.cn'
// env:uat
const domain = 'https://dj.test.glsx.com.cn';
// const domain = 'https://dj.test.glsx.com.cn'
// env:prod
// const domain = 'https://dj.glsx.com.cn';
// const domain = 'https://dj.glsx.com.cn'
const app = getApp();
const app = getApp()
/**
* 通用请求
......@@ -19,17 +20,17 @@ const app = getApp();
*/
function request(url, data, header, method, dataType, responseType, success, fail) {
//埋点
var requestStartTime = Date.now();
wx.showNavigationBarLoading();
var requestStartTime = Date.now()
wx.showNavigationBarLoading()
// 请求超时时间默认60秒
var timeout = 60000;
var timeout = 60000
if (header && header['request-timeout']) {
timeout = header['request-timeout'];
delete header['request-timeout'];
timeout = header['request-timeout']
delete header['request-timeout']
}
// 设置请求头,携带Cookie信息
setHeader(header);
var that = this;
setHeader(header)
var that = this
wx.request({
url: domain + url,
data: data,
......@@ -40,30 +41,30 @@ function request(url, data, header, method, dataType, responseType, success, fai
responseType: responseType,
success: function (response) {
// 未登录
setHeader(response.header);
setHeader(response.header)
if (response.statusCode == 401) {
// 跳转到正在登录页面
wx.navigateTo({
url: '/pages/auth/login/login'
});
})
} else if (response.statusCode == 200) {
success(response.data);
success(response.data)
} else {
if (fail && 'function' === typeof fail) {
fail();
fail()
}
}
},
fail: function (error) {
console.log('error:' + JSON.stringify(error));
console.log('error:' + JSON.stringify(error))
if (fail && 'function' === typeof fail) {
fail();
fail()
}
},
complete: function (data) {
wx.hideNavigationBarLoading();
wx.hideNavigationBarLoading()
}
});
})
}
/**
......@@ -72,40 +73,37 @@ function request(url, data, header, method, dataType, responseType, success, fai
* return 包含Cookie信息header
*/
function setHeader(header) {
var app = getApp();
var app = getApp()
if (app && app.globalData.extConfig.merchantId) {
header['MerchantId'] = app.globalData.extConfig.merchantId;
header['MerchantId'] = app.globalData.extConfig.merchantId
}
var sessionKey = 'DJ_S_';
var sessionKey = 'DJ_S_'
// 本地获取存储的sessionId
var sessionId = wx.getStorageSync(sessionKey);
var sessionId = wx.getStorageSync(sessionKey)
if (sessionId) {
// 优先从本地获取sessionId
header['Cookie'] = [sessionKey, '=', sessionId].join('');
return header;
header['Cookie'] = [sessionKey, '=', sessionId].join('')
return header
}
// 本地没有,则从服务器获取
var cookies = header['Set-Cookie'];
var cookies = header['Set-Cookie']
if (cookies) {
var re = new RegExp("" + sessionKey + "\=([^\;]*)", "ig");
sessionId = ((cookies.match(re)) ? (cookies.match(re)[0].substr(sessionKey.length + 1)) : null);
var re = new RegExp('' + sessionKey + '=([^;]*)', 'ig')
sessionId = cookies.match(re) ? cookies.match(re)[0].substr(sessionKey.length + 1) : null
if (sessionId) {
// 从cookie中获取sessionId存储到本地
wx.setStorageSync(sessionKey, sessionId);
wx.setStorageSync(sessionKey, sessionId)
}
}
if (sessionId) {
header['Cookie'] = [sessionKey, '=', sessionId].join('');
header['Cookie'] = [sessionKey, '=', sessionId].join('')
}
return header;
return header
}
function relogin() {
}
function relogin() {}
module.exports = {
/**
* 域名
*/
......@@ -120,28 +118,46 @@ module.exports = {
* 获取会话ID
*/
getSessionId: function () {
return wx.getStorageSync(djSessionId);
return wx.getStorageSync(djSessionId)
},
/**
* 利用jscode登录
* code: 登录凭证
* appId: 应用ID
* success: 成功返回处理
* success: 成功返回处理
*/
jscodeLogin: function (code, appId, success) {
request('/web-dj-weapp/jscode/login', {
code: code,
appId: appId
}, {}, 'GET', 'json', 'text', success);
request(
'/web-dj-weapp/jscode/login',
{
code: code,
appId: appId
},
{},
'GET',
'json',
'text',
success
)
},
/**
* 获取门店信息
*/
getMerchantBussiness(merchantId, success, fail) {
request('/web-dj-weapp/servicer/getMerchantBussiness', {
merchantId: merchantId
}, {}, 'GET', 'json', 'text', success, fail);
request(
'/web-dj-weapp/servicer/getMerchantBussiness',
{
merchantId: merchantId
},
{},
'GET',
'json',
'text',
success,
fail
)
},
/**
......@@ -149,9 +165,18 @@ module.exports = {
* wechatAuthSetting:微信授权信息
*/
authLogin: function (wechatAuthSetting, success, fail) {
request('/web-dj-weapp/auth/login', JSON.stringify(wechatAuthSetting), {
'content-type': 'application/json'
}, 'POST', 'json', 'text', success, fail);
request(
'/web-dj-weapp/auth/login',
JSON.stringify(wechatAuthSetting),
{
'content-type': 'application/json'
},
'POST',
'json',
'text',
success,
fail
)
},
/**
......@@ -159,9 +184,17 @@ module.exports = {
* wechatAuthSetting:微信授权信息
*/
authPhone: function (wechatAuthSetting, success) {
request('/web-dj-weapp/auth/phone', JSON.stringify(wechatAuthSetting), {
'content-type': 'application/json'
}, 'POST', 'json', 'text', success);
request(
'/web-dj-weapp/auth/phone',
JSON.stringify(wechatAuthSetting),
{
'content-type': 'application/json'
},
'POST',
'json',
'text',
success
)
},
/**
......@@ -169,7 +202,7 @@ module.exports = {
* appId: 应用ID
*/
getHeadImage: function (appId, success) {
request('/web-dj-weapp/' + appId + '/headimage/get', null, {}, 'GET', 'json', 'text', success);
request('/web-dj-weapp/' + appId + '/headimage/get', null, {}, 'GET', 'json', 'text', success)
},
/**
......@@ -177,47 +210,73 @@ module.exports = {
* merchantId:商户号
*/
getAppInfo: function (merchantId, success) {
request('/web-dj-weapp/appinfo/get', {
merchantId: merchantId
}, {
'MerchantId': merchantId
}, 'GET', 'json', 'text', success);
request(
'/web-dj-weapp/appinfo/get',
{
merchantId: merchantId
},
{
MerchantId: merchantId
},
'GET',
'json',
'text',
success
)
},
/** 我的消息 - 获取最新未读客服信息内容 */
getCustomerMessageNew: function (data, success, fail) {
request('/web-dj-weapp/remindServiceInfo/getCustomerMessageNew', data, {
'content-type': 'application/json'
}, 'POST', 'json', 'text', success, fail);
request(
'/web-dj-weapp/remindServiceInfo/getCustomerMessageNew',
data,
{
'content-type': 'application/json'
},
'POST',
'json',
'text',
success,
fail
)
},
/**
* 分享二维码
*/
createQrcode: function (vo, success, fail) {
request('/web-dj-weapp/servicer/createQrcode', vo, {}, 'GET', 'json', 'text', success, fail);
request('/web-dj-weapp/servicer/createQrcode', vo, {}, 'GET', 'json', 'text', success, fail)
},
/**
* 根据场景id获取场景值
*/
qrCodeScene: function (qrcodeScene, success, fail) {
request('/web-dj-weapp/home/qrCodeScene/getSceneById', qrcodeScene, {}, 'GET', 'json', 'text', success, fail);
request('/web-dj-weapp/home/qrCodeScene/getSceneById', qrcodeScene, {}, 'GET', 'json', 'text', success, fail)
},
/**
* 退出登录
* @param {成功回调方法} success
* @param {失败回调方法} fail
* @param {成功回调方法} success
* @param {失败回调方法} fail
*/
logout: function (success, fail) {
request('/web-dj-weapp/logout', {}, {}, 'GET', 'json', 'text', success, fail);
request('/web-dj-weapp/logout', {}, {}, 'GET', 'json', 'text', success, fail)
},
/**
* 页面访问数据收集
* @param {收集数据} data
* @param {成功回调方法} success
* @param {失败回调方法} fail
* @param {收集数据} data
* @param {成功回调方法} success
* @param {失败回调方法} fail
*/
pageVisitCollect: function (data, success, fail) {
request('/web-dj-weapp/page/visit/collect', data, {
'content-type': 'application/json'
}, 'POST', 'json', 'text', success, fail);
request(
'/web-dj-weapp/page/visit/collect',
data,
{
'content-type': 'application/json'
},
'POST',
'json',
'text',
success,
fail
)
}
}
\ No newline at end of file
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!