Commit d72dfac2 by 张立顺

feat:v4.8.0 功能开发完成

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