Commit 588189ba by 张立顺

v4.8.0 生产环境代码

1 parent 41b3dcfa
## 预发布环境appId
wx902f0b9c4b2c669d
appsecret(小程序秘钥)55c50d6b63cec072a74288a628395ca0
## 其他环境的appId
wx06d1198e751435d1
sass+ v4.8.0 微信扫码支付功能开发
\ No newline at end of file
// packagesPayment/pages/QRPayment/QRPayment.js
// import api from '../../restapiQrPay'
import api from '../../restapi'
const util = require('../../../utils/util.js')
const app = getApp()
......@@ -17,14 +18,15 @@ Page({
unpaid: true,
showOrderInfo: false,
transactionReferenceNumber: '',
dataTime: '',
orderInfoList: [
// { name: 'merchantName', label: '商户名称', info: '' },
// { name: 'outTradeNo', label: '交易参考号', info: '' },
{ name: 'tradeNo', label: '流水号', info: '' },
{ name: 'payTime', label: '支付时间', info: '' }
],
openId: 'oQ6Sh5cGirPd55Oc1J1oJSRpboFM',
// openId: '',
// openId: 'oQ6Sh5cGirPd55Oc1J1oJSRpboFM',
openId: '',
outTradeNo: ''
},
......@@ -34,6 +36,7 @@ Page({
onLoad: function (options) {
// console.log('app', app.globalData.login())
console.log(options)
this.gteOpenId()
wx.hideHomeButton({
success: function () {
......@@ -81,6 +84,7 @@ Page({
var self = this
// self.globalData.code = res.code
console.log('login', res)
console.log(api)
// restapi.jsTestLogin(res.code, self.globalData.appId, function (response) {
api.authOpenId({ code: res.code, appId: app.globalData.appId }, function (response) {
console.log('response', response)
......@@ -188,21 +192,32 @@ Page({
// 调用支付接口生成对应的微信支付参数
// console.log(params)
// return
api.createWxPayOrderH5(params, res => {
util.hideLoading()
console.log(res)
let { returnCode, data } = res
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
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))
},
fail => {
console.log(fail)
util.hideLoading()
wx.showToast({
title: '支付请求失败',
icon: 'error'
})
_this.wxPayment(jsapiPayInfo)
}
// console.log(JSON.parse(res.data))
})
)
// api.queryPayOrderStatus(params, res => {
// // util.hideLoading()
// console.log(res)
......@@ -230,11 +245,18 @@ Page({
success: function (res) {
console.log(res)
// 查询订单信息
util.showLoading('加载中...')
// util.showLoading('加载中...')
wx.setNavigationBarTitle({
title: '支付完成'
})
_this.successInfo()
_this.setData({
unpaid: false,
dataTime: new Date().format('yyyy/MM/dd hh:mm')
// showOrderInfo: data ? true : false,
// orderInfoList
})
// 银盛接口取消调用(太慢没意义)
// _this.successInfo()
},
fail: function (error) {
wx.showToast({
......
......@@ -71,16 +71,20 @@
<view class="label">商户名称</view>
<view class="info">{{merchantName}}</view>
</view>
<!-- <view class="orderInfo">
<view class="label">交易参考号</view>
<view class="orderInfo">
<view class="label">支付订单号</view>
<view class="info">{{outTradeNo}}</view>
</view> -->
<block wx:for="{{orderInfoList}}" wx:for-item="item" wx:key="index">
</view>
<view class="orderInfo">
<view class="label">支付时间</view>
<view class="info">{{dataTime}}</view>
</view>
<!-- <block wx:for="{{orderInfoList}}" wx:for-item="item" wx:key="index">
<view class="orderInfo" wx:if="{{item.info}}">
<view class="label">{{item.label}}</view>
<view class="info">{{item.info}}</view>
</view>
</block>
</block> -->
<image class="logoIcon" src="../../../images/djLogin.png" />
</view>
</view>
......
// const restapi = require('../utils/util.js');
const restapi = require('../utils/restapi.js')
module.exports = {
/** 获取订单数据*/
GETORDERINFO: function (oParams, success, fail) {
......@@ -57,7 +57,6 @@ module.exports = {
'/web-dj-weapp/jscode/getOpenId',
// JSON.stringify(code),
params,
{
'content-type': 'application/x-www-form-urlencoded'
},
......
// const restapi = require('../utils/util.js')
const domain = 'https://dj.test.glsx.com.cn'
// import restapi from '../utils/restapi.js'
// console.log(restapi)
// const restapi = require('../utils/restapi.js')
const restapi = {}
restapi.req = request
console.log(restapi.req)
/**
* 通用请求
* url: 请求路径
* data: 数据参数
* header: 请求头
* method: 请求类型,默认GET,需大写
* dataType: 返回数据格式,默认json
* responseType: 响应数据类型,默认text
* success: 响应成功回调函数
*/
function request(url, data, header, method, dataType, responseType, success, fail) {
//埋点
var requestStartTime = Date.now()
wx.showNavigationBarLoading()
// 请求超时时间默认60秒
var timeout = 60000
if (header && header['request-timeout']) {
timeout = header['request-timeout']
delete header['request-timeout']
}
// 设置请求头,携带Cookie信息
setHeader(header)
var that = this
wx.request({
url: 'https://dj.test.glsx.com.cn' + url,
data: data,
header: header,
timeout: timeout,
method: method,
dataType: dataType,
responseType: responseType,
success: function (response) {
// 未登录
setHeader(response.header)
if (response.statusCode == 401) {
// 跳转到正在登录页面
wx.navigateTo({
url: '/pages/auth/login/login'
})
} else if (response.statusCode == 200) {
success(response.data)
} else {
if (fail && 'function' === typeof fail) {
fail()
}
}
},
fail: function (error) {
console.log('error:' + JSON.stringify(error))
if (fail && 'function' === typeof fail) {
fail()
}
},
complete: function (data) {
wx.hideNavigationBarLoading()
}
})
}
/**
* 设置请求头Cookie信息
* header 源请求头信息
* return 包含Cookie信息header
*/
function setHeader(header) {
var app = getApp()
if (app && app.globalData.extConfig.merchantId) {
header['MerchantId'] = app.globalData.extConfig.merchantId
}
var sessionKey = 'DJ_S_'
// 本地获取存储的sessionId
var sessionId = wx.getStorageSync(sessionKey)
if (sessionId) {
// 优先从本地获取sessionId
header['Cookie'] = [sessionKey, '=', sessionId].join('')
return header
}
// 本地没有,则从服务器获取
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
if (sessionId) {
// 从cookie中获取sessionId存储到本地
wx.setStorageSync(sessionKey, sessionId)
}
}
if (sessionId) {
header['Cookie'] = [sessionKey, '=', sessionId].join('')
}
return header
}
module.exports = {
/** 获取订单数据*/
GETORDERINFO: function (oParams, success, fail) {
restapi.req('/web-dj-weapp/smartcarlife/goodsOrder/createWxPayOrder', oParams, {}, 'GET', 'json', 'text', success, fail)
},
/**
* 根据场景id获取场景值
*/
qrCodeScene: function (qrcodeScene, success, fail) {
restapi.req('/web-dj-weapp/home/qrCodeScene/getSceneById', qrcodeScene, {}, 'GET', 'json', 'text', success, fail)
},
/** 查询支付结果 */
queryPayOrderStatus: function (params, success, fail) {
restapi.req(
'/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'
},
'POST',
'json',
'text',
success,
fail
)
}
}
......@@ -4,7 +4,7 @@
"ignore": []
},
"setting": {
"urlCheck": false,
"urlCheck": true,
"es6": false,
"enhance": true,
"postcss": true,
......@@ -30,7 +30,6 @@
"disablePlugins": [],
"outputPath": ""
},
"enableEngineNative": false,
"useIsolateContext": true,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
......@@ -39,10 +38,11 @@
"disableUseStrict": false,
"minifyWXML": true,
"showES6CompileOption": false,
"useCompilerPlugins": false
"useCompilerPlugins": false,
"ignoreUploadUnusedFiles": true
},
"compileType": "miniprogram",
"libVersion": "2.21.0",
"libVersion": "2.8.3",
"appid": "wx06d1198e751435d1",
"projectname": "dj-scrm-weapp-smartshop",
"debugOptions": {
......
......@@ -279,6 +279,13 @@
"query": "scene=sceneId%3D4",
"scene": null,
"launchMode": "default"
},
{
"name": "",
"pathName": "packagePersonal/pages/address/address",
"query": "",
"launchMode": "default",
"scene": null
}
]
}
......
......@@ -2,9 +2,9 @@
// 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()
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!