Commit 24f3cf7d by 张立顺

Merge branch 'dev_v4.24.2' into develop

2 parents fb6b64bb 2a2dadbc
...@@ -260,7 +260,7 @@ App({ ...@@ -260,7 +260,7 @@ App({
* 登录成功回调 * 登录成功回调
*/ */
loginSuccessCallback: function (userInfo) { loginSuccessCallback: function (userInfo) {
console.log(userInfo) // console.log(userInfo)
this.globalData.userInfo = userInfo this.globalData.userInfo = userInfo
this.globalData.accountId = userInfo.accountId this.globalData.accountId = userInfo.accountId
// this.getCustomerMessageNew(userInfo.accountId) // this.getCustomerMessageNew(userInfo.accountId)
......
...@@ -54,21 +54,29 @@ Component({ ...@@ -54,21 +54,29 @@ Component({
}, },
jump(e) { jump(e) {
console.log(e) console.log(e)
var globalData = appInstance.globalData.extConfig
let { let {
url url
} = e.currentTarget.dataset } = e.currentTarget.dataset
restapi.getMerchantBussiness(globalData.merchantId, function (res) { const baseUrl = 'https://img02.glsx.com.cn/weapp/resource/saas/scrm/html/'
// console.log(res); const path = `${baseUrl}${url}.html`
if (res.returnCode == '0') { // private user
let path = `https://dj.glsx.com.cn/agreement/djUserPolicy.html?merchantName=${globalData.merchantName}&phone=${res.data.phone}` wx.navigateTo({
wx.navigateTo({ url: `/pages/webpage/webpage?path=${encodeURIComponent(path)}`
url: `/pages/webpage/webpage?path=${encodeURIComponent(path)}` })
}) // var globalData = appInstance.globalData.extConfig
}
}, function (res) {
console.log(res); // restapi.getMerchantBussiness(globalData.merchantId, function (res) {
}) // console.log(res);
// if (res.returnCode == '0') {
// let path = `https://dj.glsx.com.cn/agreement/djUserPolicy.html?merchantName=${globalData.merchantName}&phone=${res.data.phone}`
// wx.navigateTo({
// url: `/pages/webpage/webpage?path=${encodeURIComponent(path)}`
// })
// }
// }, function (res) {
// console.log(res);
// })
}, },
// 获取小程序头像 // 获取小程序头像
getHeadImage() { getHeadImage() {
......
...@@ -24,7 +24,8 @@ ...@@ -24,7 +24,8 @@
</view> </view>
阅读并同意以下协议 阅读并同意以下协议
<!-- <text catchtap="jump" data-url="agree">《服务协议》</text> --> <!-- <text catchtap="jump" data-url="agree">《服务协议》</text> -->
<text catchtap="jump" data-url="private">《隐私政策》</text> <text catchtap="jump" data-url="privacy">《隐私协议》</text>
<text catchtap="jump" data-url="agreement">《用户协议》</text>
</view> </view>
</view> </view>
......
/**
* 用来配置小程序项目的变量
* 统一管理
*/
/**
* 环境指定
* 0本地
* 1开发
* 2测试
* 3生产环境
*/
let index = 2
const accountInfo = wx.getAccountInfoSync()
const systemInfo = wx.getSystemInfoSync()
const envName = accountInfo.miniProgram.envVersion
//手动控制体验版环境的请求 true就依据下面index false就默认为2
const manual = false
const release = false
// 判断小程序环境
// develop:开发版 trial:体验版 release:正式版
if (systemInfo.platform != 'devtools') {
switch (envName) {
case 'develop':
break
case 'trial':
index = manual ? index : 2
break
case 'release':
index = release ? index : 3
break
default:
index = 3
break
}
}
export const env = envName
export const envIndex = index
const createOrderPosterImgUrl = {
develop: `http://192.168.1.178:9528/dj-scrm-wx-work-main-zhangls/#/orderDetailPoster?`,
trial: `http://frontend.test.glsx.com.cn/dj-car-boutique-work-wechat/#/orderDetailPoster?`,
release: `https://dj.glsx.com.cn/dj-car-boutique-work-wechat/#/orderDetailPoster?`
}
const target = ['ip', 'develop', 'trial', 'release', 'preRelease']
// 订单详情地址
export const orderPosterImgUrl = createOrderPosterImgUrl[target[envIndex]]
// 配置预发布的小程序aapId
// export const preReleaseAppId = 'wx24ebae5768e74138'
// 小程序id
// export const appId = 'wx570d9331f9ace0bd'
// sentry Dsn 地址
// export const dsnUrl = 'https://ddaadc52bf8d4ecc92eca632683d456a@sentry.glsx.com.cn/23'
// 图片基地址
// export const ImgUrl = 'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat'
// packageCrowdfunding/components/createImage/index.js
import Draw from '~/utils/Draw'
import { IMG_URL } from '~/utils/constantData'
Component({
externalClasses: ['custom-class', 'class'],
/**
* 组件的属性列表
*/
properties: {
mode: {
type: String,
value: 'widthFix'
},
orderInfo: {
type: Object,
value: {},
observer: function (n) {
if (n) {
const fn = wx.getFileSystemManager()
fn.readdir({
dirPath: wx.env.USER_DATA_PATH,
success({ files }) {
files.length &&
files.map(e => {
fn.unlink({
filePath: `${wx.env.USER_DATA_PATH}/${e}`
})
})
}
})
let _this = this
_this.drawOrderImg()
}
}
}
},
/**
* 组件的初始数据
*/
data: {
ctx: '',
imagePath: ''
},
/**
* 组件的方法列表
*/
methods: {
// 画图
async drawOrderImg(callBack) {
let _this = this
let { plateNo, payPrice, userName, goodsName, orderNumber, orderStatus, goodsNumber, createdDate, vehicleBrandName, vehicleShapeName, formContentFirst, vehicleSeriesName, formDescribeFirst, formContentSecond, formDescribeSecond, vehicleSubBrandName, phone } = this.data.orderInfo
let valueX = 95,
labelX = 17,
fontSize = 14,
valueEndX = 320 - fontSize / 2,
textBaseline = 'top',
canvasWidth = 337,
canvasHeight = 561,
carText = '',
labelList = ['客户姓名:'],
spacing = 0,
textYList = [],
labelEndX = 80,
lineNum = 2,
lineHeight = 24,
valueList = [userName]
const draw = new Draw(
{
width: canvasWidth,
height: canvasHeight
},
_this
)
if (phone) {
labelList.push('手机号:')
valueList.push(phone)
}
if (plateNo) {
labelList.push('车牌号:')
valueList.push(plateNo)
}
if (vehicleBrandName) {
carText = `${vehicleBrandName || ''} ${vehicleSubBrandName || ''} ${vehicleSeriesName || ''} ${vehicleShapeName || ''}`
labelList.push('车型:')
valueList.push(carText)
}
console.log(new Date(createdDate).format('yyyy年M月d日 hh:mm:ss'))
labelList = [...labelList, '商品名称:', '支付时间:']
// valueList = [...valueList, `${goodsName}${goodsNumber > 1 ? `*${goodsNumber}` : ''}` , new Date(createdDate).format('yyyy年M月d日 hh:mm:ss')]
valueList = [...valueList, goodsName, new Date(createdDate).format('yyyy年M月d日 hh:mm:ss')]
if (orderStatus != 10 && orderNumber) {
labelList.push('订单号:')
valueList.push(orderNumber)
}
if (formContentFirst) {
labelList.push(formDescribeFirst)
valueList.push(formContentFirst)
}
if (formContentSecond) {
labelList.push(formDescribeSecond)
valueList.push(formContentSecond)
}
labelList.push('支付定金')
valueList.push(`${payPrice}元`)
labelList.map((e, index) => {
if (e == '商品名称:' && draw.getTextWidth(carText, fontSize) > valueEndX - valueX) spacing = lineHeight
if ((e == formDescribeSecond && draw.getTextWidth(formContentFirst, fontSize) > valueEndX - valueX) || (e === formDescribeSecond && draw.getTextWidth(formDescribeFirst, fontSize) > labelEndX - labelX)) spacing = lineHeight * 2
if (index == labelList.length - 1) textYList.push(493)
else textYList.push(index * 32 + 109 + spacing)
})
const imgName = {
8: '-2',
10: '-3'
}[orderStatus]
let textList = []
;(labelList || []).map((e, index) => {
let y = textYList[index] + fontSize / 2
let label = {
text: e,
x: labelX,
y,
color: '#999',
fontSize,
textBaseline
}
let value = {
text: valueList[index],
x: valueX,
y,
color: '#282829',
fontSize,
textBaseline,
width: valueEndX
}
if (e === '商品名称:') {
value.color = '#FC5B32'
value.lineNum = 3
}
if ((formDescribeFirst && e === formDescribeFirst) || (formDescribeSecond && e === formDescribeSecond) || e === '品牌车型:') {
value.lineNum = lineNum
value.lineHeight = lineHeight
if ((formDescribeFirst && e === formDescribeFirst) || (formDescribeSecond && e === formDescribeSecond)) {
label.lineNum = lineNum
label.lineHeight = lineHeight
label.width = labelEndX
label.lastFont = ':'
}
}
if (e === '支付定金') {
label.color = '#282829'
value.color = orderStatus == 8 ? '#3162E6' : '#F13C3D'
value.fontWeight = '600'
value.fontSize = 18
value.y = textYList[index] + 5
}
if (orderStatus == 10) {
textList.push({
text: '订单号',
x: labelX - 1,
y: 24,
color: '#282829',
fontSize,
textBaseline,
lineNum: 3
})
textList.push({
text: orderNumber || '',
x: labelX - 1,
y: 54,
color: '#282829',
fontSize,
textBaseline,
lineNum: 3
})
}
textList.push(label)
textList.push(value)
})
let res = await draw.begin({
imageList: [
{
url: `${IMG_URL}crowdfunding/order-bg${imgName || ''}.png`,
x: 0,
y: 0,
width: canvasWidth,
height: canvasHeight
}
],
textList: textList,
lineList: [
{
startX: labelX,
startY: 478,
endX: 320,
endY: 478,
width: 0.1,
color: '#F1F1F1'
}
]
})
this.setData({
imagePath: res.path
})
console.log(res.path)
}
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
/* packageCrowdfunding/components/createImage/index.wxss */
\ No newline at end of file \ No newline at end of file
<!--packageCrowdfunding/components/createImage/index.wxml-->
<image src="{{imagePath}}" class="custom-class" mode="{{mode}}" show-menu-by-longpress />
\ No newline at end of file \ No newline at end of file
/** // /**
* // *
0本地 // 0本地
1开发 // 1开发
2测试 // 2测试
3生产环境 // 3生产环境
*/ // */
const accountInfo = wx.getAccountInfoSync() // const accountInfo = wx.getAccountInfoSync()
const systemInfo = wx.getSystemInfoSync() // const systemInfo = wx.getSystemInfoSync()
// console.log(systemInfo); // // console.log(systemInfo);
// console.log(accountInfo.miniProgram.envVersion) // // console.log(accountInfo.miniProgram.envVersion)
//手动控制体验版环境的请求 true就依据下面index false就默认为2 // //手动控制体验版环境的请求 true就依据下面index false就默认为2
const manual = false // const manual = false
const release = false // const release = false
let index = 3 // let index = 3
// 判断小程序环境 // // 判断小程序环境
// develop:开发版(正常开发工具,测试时) // // develop:开发版(正常开发工具,测试时)
// trial:体验版 // // trial:体验版
// release:正式版 // // release:正式版
// console.log( systemInfo.platform); // // console.log( systemInfo.platform);
// console.log(accountInfo.miniProgram.envVersion); // // console.log(accountInfo.miniProgram.envVersion);
if (systemInfo.platform != 'devtools') { // if (systemInfo.platform != 'devtools') {
switch (accountInfo.miniProgram.envVersion) { // switch (accountInfo.miniProgram.envVersion) {
case 'develop': // case 'develop':
// this.globalData.url = 'http://192.168.0.252:3000/api'; // // // this.globalData.url = 'http://192.168.0.252:3000/api'; //
break // break
case 'trial': // case 'trial':
index = manual ? index : 2 // index = manual ? index : 2
break // break
case 'release': // case 'release':
index = release? index : 3 // index = release? index : 3
break // break
default: // default:
index = 3 // index = 3
break // break
} // }
} // }
import { envIndex } from '~/config'
let index = envIndex
// console.log(index); // console.log(index);
const secretKey_items = { const secretKey_items = {
...@@ -60,7 +62,7 @@ const secretKey_items = { ...@@ -60,7 +62,7 @@ const secretKey_items = {
} }
const domain_items = { const domain_items = {
// ip: 'http://192.168.2.59:8292', // ip: 'http://192.168.2.59:8292',
ip:'http://192.168.1.129:8392', ip: 'http://192.168.1.129:8392',
// ip: 'http://192.168.2.3:8292', // ip: 'http://192.168.2.3:8292',
dev: 'https://dj.dev.glsx.com.cn', dev: 'https://dj.dev.glsx.com.cn',
uat: 'https://dj.test.glsx.com.cn', uat: 'https://dj.test.glsx.com.cn',
......
...@@ -28,6 +28,7 @@ const sign = (params, secret, noSignAttr = []) => { ...@@ -28,6 +28,7 @@ const sign = (params, secret, noSignAttr = []) => {
} }
realObj[key] = obj realObj[key] = obj
} }
// console.log(noSignAttr,'noSignAttr');
keys.forEach(e => { keys.forEach(e => {
!noSignAttr.includes(e) && str.push(e + realObj[e]) !noSignAttr.includes(e) && str.push(e + realObj[e])
}) })
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
import api from '../../restapi' import api from '../../restapi'
const util = require('../../../utils/util.js') const util = require('../../../utils/util.js')
const app = getApp() const app = getApp()
import { orderPosterImgUrl } from '~/config'
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
...@@ -26,6 +27,7 @@ Page({ ...@@ -26,6 +27,7 @@ Page({
{ name: 'tradeNo', label: '流水号', info: '' }, { name: 'tradeNo', label: '流水号', info: '' },
{ name: 'payTime', label: '支付时间', info: '' } { name: 'payTime', label: '支付时间', info: '' }
], ],
posterUrl: '',
openId: 'oQ6Sh5cGirPd55Oc1J1oJSRpboFM', openId: 'oQ6Sh5cGirPd55Oc1J1oJSRpboFM',
// openId: '', // openId: '',
outTradeNo: '', outTradeNo: '',
...@@ -42,7 +44,8 @@ Page({ ...@@ -42,7 +44,8 @@ Page({
onLoad: function (options) { onLoad: function (options) {
// console.log('app', app.globalData.login()) // console.log('app', app.globalData.login())
// console.log(aa) // console.log(aa)
// 开发用
// this.getOrderScreenShot()
this.gteOpenId() this.gteOpenId()
wx.hideHomeButton({ wx.hideHomeButton({
success: function () { success: function () {
...@@ -185,9 +188,9 @@ Page({ ...@@ -185,9 +188,9 @@ Page({
}, },
// 隐藏键盘 // 隐藏键盘
handleHiddenKey() { handleHiddenKey() {
this.setData({ // this.setData({
keyHidden: true // keyHidden: true
}) // })
}, },
// 显示键盘 // 显示键盘
handleShowKey() { handleShowKey() {
...@@ -263,7 +266,7 @@ Page({ ...@@ -263,7 +266,7 @@ Page({
res => { res => {
util.hideLoading() util.hideLoading()
// console.log(res) // console.log(res)
let { returnCode, data } = res let { returnCode, data, message } = res
if (returnCode == 0) { if (returnCode == 0) {
let jsapiPayInfo = data.jsapiPayInfo ? JSON.parse(data.jsapiPayInfo) : {} let jsapiPayInfo = data.jsapiPayInfo ? JSON.parse(data.jsapiPayInfo) : {}
...@@ -272,6 +275,11 @@ Page({ ...@@ -272,6 +275,11 @@ Page({
outTradeNo: data.outTradeNo outTradeNo: data.outTradeNo
}) })
_this.wxPayment(jsapiPayInfo) _this.wxPayment(jsapiPayInfo)
} else {
wx.showToast({
title: message || returnCode == -1 ? '发起支付失败' : '支付请求失败',
icon: 'error'
})
} }
// console.log(JSON.parse(res.data)) // console.log(JSON.parse(res.data))
}, },
...@@ -309,7 +317,7 @@ Page({ ...@@ -309,7 +317,7 @@ Page({
timeStamp: row.timeStamp, timeStamp: row.timeStamp,
signType: 'MD5', signType: 'MD5',
success: function (res) { success: function (res) {
// console.log(res) console.log(res)
// 查询订单信息 // 查询订单信息
// util.showLoading('加载中...') // util.showLoading('加载中...')
wx.setNavigationBarTitle({ wx.setNavigationBarTitle({
...@@ -317,10 +325,11 @@ Page({ ...@@ -317,10 +325,11 @@ Page({
}) })
_this.setData({ _this.setData({
unpaid: false, unpaid: false,
dataTime: new Date().format('yyyy/MM/dd hh:mm') dataTime: new Date().format('yyyy年MM月dd hh:mm:ss')
// showOrderInfo: data ? true : false, // showOrderInfo: data ? true : false,
// orderInfoList // orderInfoList
}) })
_this.getOrderScreenShot()
// 银盛接口取消调用(太慢没意义) // 银盛接口取消调用(太慢没意义)
// _this.successInfo() // _this.successInfo()
}, },
...@@ -335,31 +344,39 @@ Page({ ...@@ -335,31 +344,39 @@ Page({
}, },
// 支付成功获取订单回调信息 // 支付成功获取订单回调信息
successInfo() { // successInfo() {
let { outTradeNo, orderInfoList, showOrderInfo } = this.data // let { outTradeNo, orderInfoList, showOrderInfo } = this.data
api.queryPayOrderStatus( // api.queryPayOrderStatus(
{ outTradeNo }, // { outTradeNo },
res => { // res => {
util.hideLoading() // util.hideLoading()
console.log(res) // console.log(res)
let { data, returnCode } = res // let { data, returnCode } = res
if (returnCode == 0) { // if (returnCode == 0) {
data && // this.setData({
orderInfoList.forEach(element => { // orderCode: data.orderCode
element['info'] = data[element['name']] // })
}) // }
this.setData({ // },
unpaid: false, // rej => {
showOrderInfo: data ? true : false, // console.log(rej)
orderInfoList // util.hideLoading()
}) // }
} // )
// let { returnCode, data } = res // },
}, getOrderScreenShot() {
rej => { let { merchantName, shopMerchantName, dataTime, outTradeNo, payMoney, isYqType } = this.data
console.log(rej) let params = JSON.stringify({ merchantName: isYqType ? merchantName : shopMerchantName, formatAccountDate: dataTime, selectPayType: 1, outTradeNo, payMoney })
util.hideLoading() console.log(params, 'params')
} api
) .orderScreenShot({ url: orderPosterImgUrl + 'orderInfo=' + params })
.then(result => {
// this.poster = res.data
console.log(result, 'poster')
this.setData({
posterUrl: result.data
})
})
.catch(err => {})
} }
}) })
<!-- packagesPayment/pages/QRPayment/QRPayment.wxml --> <!-- packagesPayment/pages/QRPayment/QRPayment.wxml -->
<!-- 二维码支付 --> <!-- 二维码支付 -->
<view wx:if="{{unpaid}}"> <view wx:if="{{ unpaid }}">
<!-- <web-view src="https://img02.glsx.com.cn/zfSPSBsHw1.txt" /> --> <!-- <web-view src="https://img02.glsx.com.cn/zfSPSBsHw1.txt" /> -->
<view class="pay-container" catchtap="handleHiddenKey"> <view class="pay-container" catchtap="handleHiddenKey">
<view class="pay-header payCompanyInfo"> <view class="pay-header payCompanyInfo">
<!-- <view class=""> --> <!-- <view class=""> -->
<image class="shopIcon" src="../../../images/shopIcon.png" /> <image class="shopIcon" src="../../../images/shopIcon.png" />
<view class="company" wx:if="{{isYqType}}"> <view class="company" wx:if="{{ isYqType }}">
<view class="company-name">深圳市嘀加智慧云服务有限公司</view> <view class="company-name">深圳市嘀加智慧云服务有限公司</view>
<view class="company-yqd">{{merchantName}}</view> <view class="company-yqd">{{merchantName}}</view>
</view> </view>
...@@ -23,17 +23,13 @@ ...@@ -23,17 +23,13 @@
<view class="pay-input-wrapper" catchtap="handleShowKey"> <view class="pay-input-wrapper" catchtap="handleShowKey">
<!-- <text class="pay-icon">¥</text> --> <!-- <text class="pay-icon">¥</text> -->
<text class="pay-icon">金额</text> <text class="pay-icon">金额</text>
<view hidden="{{!payMoney}}" class="pay-money">{{ payMoney }}</view> <view hidden="{{ !payMoney }}" class="pay-money">{{ payMoney }}</view>
<view hidden="{{keyHidden}}" class="pay-cursor" /> <view hidden="{{ keyHidden }}" class="pay-cursor" />
<view class="pay-after-icon">元</view> <view class="pay-after-icon">元</view>
</view> </view>
<view class="userCollaborationContainer" wx:if="{{userCollaborationName}}"> <view class="userCollaborationContainer" wx:if="{{ userCollaborationName }}">
<!-- <label class="radio"> value="{{userCollaborationCheck}}" --> <!-- <label class="radio"> value="{{userCollaborationCheck}}" -->
<radio <radio class="radio" style="transform:scale(0.6)" checked="{{ userCollaborationCheck }}" catchtap="handleRadio" />
class="radio"
style="transform:scale(0.6)"
checked="{{userCollaborationCheck}}"
catchtap="handleRadio" />
<view catchtap="handleRadio" class="label">我已阅读并同意</view> <view catchtap="handleRadio" class="label">我已阅读并同意</view>
<!-- </label> --> <!-- </label> -->
<view class="linkText" catchtap="navToUserCollaboration">《{{userCollaborationName}}》</view> <view class="linkText" catchtap="navToUserCollaboration">《{{userCollaborationName}}》</view>
...@@ -44,36 +40,32 @@ ...@@ -44,36 +40,32 @@
<view class="key-box"> <view class="key-box">
<view class="number-box clearfix"> <view class="number-box clearfix">
<view <view
wx:for="{{KeyboardKeys}}" wx:for="{{ KeyboardKeys }}"
wx:key="*this" wx:key="*this"
data-key="{{item}}" data-key="{{ item }}"
class="key {{ index === 9 ? 'key-zero' : ''}}" class="key {{ index === 9 ? 'key-zero' : '' }}"
hover-class="number-box-hover" hover-class="number-box-hover"
catchtap="handleKey"> catchtap="handleKey"
{{item}} >{{item}}</view>
</view>
</view> </view>
<view class="btn-box"> <view class="btn-box">
<!-- TODO: 需要替换成删除icon --> <!-- TODO: 需要替换成删除icon -->
<view <view class="key deletKey" hover-class="number-box-hover" data-key="X" catchtap="handleKey">
class="key deletKey"
hover-class="number-box-hover"
data-key="X"
catchtap="handleKey">
<!-- X --> <!-- X -->
<image class="deletIcon" src="../../../images/deleteIcon.png" /> <image class="deletIcon" src="../../../images/deleteIcon.png" />
</view> </view>
<view class="key pay_btn {{payMoney&&canPay ? '' : 'pay-btn-display'}}" hover-class="pay-btn-hover" catchtap="handlePay"> <view class="key pay_btn {{ payMoney&&canPay ? '' : 'pay-btn-display' }}" hover-class="pay-btn-hover" catchtap="handlePay">付款</view>
付款
</view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<view wx:if="{{!unpaid}}"> <view wx:if="{{ !unpaid }}">
<!-- <view>支付成功</view> --> <!-- <view>支付成功</view> -->
<view class="success-Container"> <view class="success-Container">
<view class="amountOfMoney">¥ {{payMoney}}</view> <view class="poster">
<image class="posetrimg" show-menu-by-longpress="true" mode="widthFix" src="{{ posterUrl }}" />
</view>
<!-- <view class="amountOfMoney">¥ {{payMoney}}</view>
<view class="success-tips"> <view class="success-tips">
<image class="successIcon" src="../../../images/successIcon.png" /> <image class="successIcon" src="../../../images/successIcon.png" />
支付成功 支付成功
...@@ -94,7 +86,7 @@ ...@@ -94,7 +86,7 @@
<view class="orderInfo"> <view class="orderInfo">
<view class="label">支付时间</view> <view class="label">支付时间</view>
<view class="info">{{dataTime}}</view> <view class="info">{{dataTime}}</view>
</view> </view> -->
<!-- <block wx:for="{{orderInfoList}}" wx:for-item="item" wx:key="index"> <!-- <block wx:for="{{orderInfoList}}" wx:for-item="item" wx:key="index">
<view class="orderInfo" wx:if="{{item.info}}"> <view class="orderInfo" wx:if="{{item.info}}">
<view class="label">{{item.label}}</view> <view class="label">{{item.label}}</view>
...@@ -106,16 +98,19 @@ ...@@ -106,16 +98,19 @@
<!-- <image bindlongpress="navWarrantyCard" class="wxqrCon" src="https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/minizhibaoka.png" /> --> <!-- <image bindlongpress="navWarrantyCard" class="wxqrCon" src="https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/minizhibaoka.png" /> -->
<!-- <image show-menu-by-longpress="true" class="wxqrCon" src="https://dj.glsx.com.cn/dj-wxaqrcode/aeabc3a60a328e8c536588686eec016b.png" /> --> <!-- <image show-menu-by-longpress="true" class="wxqrCon" src="https://dj.glsx.com.cn/dj-wxaqrcode/aeabc3a60a328e8c536588686eec016b.png" /> -->
<!-- wx:if="{{workWechatQrcode}}" --> <!-- wx:if="{{workWechatQrcode}}" -->
<block wx:if="{{qrcodeType== 1}}"> <block wx:if="{{ qrcodeType== 1 }}">
<view class="wxTips">长按识别扫码领取质保卡</view> <view class="wxTips">长按识别扫码领取质保卡</view>
<image bindlongpress="navWarrantyCard" class="wxqrCon" src="https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/minizhibaoka.png" /> <image
bindlongpress="navWarrantyCard"
class="wxqrCon"
src="https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/minizhibaoka.png"
/>
</block> </block>
<block wx:if="{{qrcodeType== 2}}"> <block wx:if="{{ qrcodeType== 2 }}">
<view class="wxTips">长按识别添加客服</view> <view class="wxTips">长按识别添加客服</view>
<image show-menu-by-longpress="true" class="wxqrCon" src="{{workWechatQrcode}}" /> <image show-menu-by-longpress="true" class="wxqrCon" src="{{ workWechatQrcode }}" />
</block> </block>
<image class="logoIcon" src="../../../images/djLogin.png" /> <image class="logoIcon" src="../../../images/djLogin.png" />
</view> </view>
</view> </view>
</view> </view>
\ No newline at end of file \ No newline at end of file
...@@ -233,7 +233,7 @@ ...@@ -233,7 +233,7 @@
} }
.success-Container { .success-Container {
padding: 100rpx 76rpx 0; padding: 10rpx 0 0;
text-align: center; text-align: center;
background-color: #fff; background-color: #fff;
height: 100vh; height: 100vh;
...@@ -324,4 +324,19 @@ ...@@ -324,4 +324,19 @@
width: 200rpx; width: 200rpx;
height: 50rpx; height: 50rpx;
}
.poster {
box-sizing: border-box;
margin: 20rpx auto;
width: 710rpx;
/* height: 964rpx; */
background: #FFFFFF;
box-shadow: 0 4rpx 20rpx 0 #0000001a;
border-radius: 16rpx;
}
.posetrimg {
width: 100%;
/* height: 100%; */
} }
\ No newline at end of file \ No newline at end of file
// packagesPayment/pages/payment/index.js // packagesPayment/pages/payment/index.js
const filter = require('../../../utils/filter.js') // const filter = require('../../../utils/filter.js')
var app = getApp() var app = getApp()
import api from '../../restapi' import api from '../../restapi'
import util from '../../../utils/util.js' import util from '../../../utils/util.js'
Page( import { orderPosterImgUrl, envName } from '~/config'
// { Page({
filter.identityFilter({ // filter.identityFilter({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
...@@ -14,14 +14,15 @@ Page( ...@@ -14,14 +14,15 @@ Page(
authType: true, // 授权类型(true:授权用户信息;false:授权手机号) authType: true, // 授权类型(true:授权用户信息;false:授权手机号)
sceneId: '', sceneId: '',
ajaxing: false, ajaxing: false,
paySuccess: false paySuccess: false,
// paySuccess: true posterUrl: '',
sceneType: true //默认是1.1的支付场景
}, },
onLogin() { onLogin() {
util.showLoading('加载中...') // util.showLoading('加载中...')
this.getScenInfo() this.data.sceneId && this.getScenInfo()
console.log(app.globalData) // console.log(app.globalData)
// if (app.globalData.userInfo || app.globalData.userInfo.phone) { // if (app.globalData.userInfo || app.globalData.userInfo.phone) {
// } // }
}, },
...@@ -30,24 +31,38 @@ Page( ...@@ -30,24 +31,38 @@ Page(
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
// options. scene= 'sceneId=10683'
// let options = {
// scene: 'sceneId=6783'
// }
wx.hideHomeButton({ wx.hideHomeButton({
success: function () { success: function () {
console.log('隐藏成功!') // console.log('隐藏成功!')
} }
}) })
console.log(options) // options.orderCode = 'S2307141727472187'
let id = decodeURIComponent(options.scene).split('=')[1] // 是别的小程序 跳转过来的
console.log(id, 'id') if (options.orderCode) {
this.setData({ this.setData({
sceneId: id otherOrderCode: options.orderCode
}) })
util.showLoading('加载中...') }
this.getScenInfo() // 开发用
// this.getOrderDetail()
// this.getOrderScreenShot()
// options.scene = 'sceneId=11188'
// options = {
// scene: 'sceneId=11188'
// }
// console.log(options, 'options')
// console.log(options)
if (options.scene) {
let id = decodeURIComponent(options.scene).split('=')[1]
// console.log(id, 'id')
this.setData({
sceneId: id
})
}
this.gteOpenId()
}, },
/** /**
...@@ -65,27 +80,95 @@ Page( ...@@ -65,27 +80,95 @@ Page(
ajaxing: false ajaxing: false
}) })
}, },
navWarrantyCard() {
// console.log('navWebview')
// console.log(wx.$router.getRouterList())
wx.$router.go('warrantyCard')
},
gteOpenId() {
let that = this
let { otherOrderCode } = this.data
// debugger
// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
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)
let { returnCode, data } = response
if (returnCode == 0) {
self.setData({
openId: data.openId
})
otherOrderCode
? that.getOrderDetail({
orderCode: otherOrderCode
})
: that.getScenInfo()
}
}
)
}
})
},
getOrderScreenShot() {
const { orderCode } = this.data
api
.orderScreenShot({
url: orderPosterImgUrl + 'orderCode=' + orderCode
})
.then(result => {
// this.poster = res.data
console.log(result, 'poster')
this.setData({
posterUrl: result.data
})
})
.catch(err => {})
},
// 获取订单信息 // 获取订单信息
getInfo: function (row) { getInfo: function (row) {
let { openId } = this.data
let _this = this let _this = this
let oParams = {} let oParams = {}
oParams.orderCode = row.orderCode oParams.orderCode = row.orderCode
oParams.workWxSessionId = row.workWxSessionId oParams.workWxSessionId = row.workWxSessionId
oParams.openId = openId
api.GETORDERINFO(oParams, res => { api.GETORDERINFO(oParams, res => {
util.hideLoading() util.hideLoading()
console.log(JSON.parse(res.data)) let { returnCode, message, data } = res
let o = res.data ? JSON.parse(res.data) : {} // console.log(res);
this.setData({ // console.log(JSON.parse(res.data))
o
}) if (returnCode == 0) {
_this.wxPayment(o) let o = data ? JSON.parse(data) : {}
this.setData({
o
})
_this.wxPayment(o)
} else {
wx.showToast({
title: message || returnCode == -1 ? '发起支付失败' : '订单支付失败',
icon: 'error'
})
}
}) })
}, },
// 调用微信支付 // 调用微信支付
wxPayment: function (row) { wxPayment: function (row) {
let _this = this let _this = this
let { otherOrderCode } = this.data
if (this.data.ajaxing) { if (this.data.ajaxing) {
return false return false
} }
...@@ -101,20 +184,37 @@ Page( ...@@ -101,20 +184,37 @@ Page(
success: function (res) { success: function (res) {
console.log(res) console.log(res)
_this.setData({ _this.setData({
paySuccess: true, paySuccess: true
dataTime: new Date().format('yyyy/MM/dd hh:mm') // dataTime: new Date().format('yyyy/MM/dd hh:mm')
}) })
wx.setNavigationBarTitle({ wx.setNavigationBarTitle({
title: '支付成功', title: '支付成功'
})
if (otherOrderCode) {
// 跳转回对应的小程序
return wx.navigateToMiniProgram({
appId: 'wxe10067a63c1856ac',
path: 'packageShopmall/packageMine/pages/order/index/index',
// appId: 'wxe10067a63c1856ac',
// path: 'pages/sceneIndex/sceneIndex',
extraData: {
// foo: 'bar'
},
// envVersion: envName,
envVersion: 'trial',
success(res) {
// 打开成功
}
}) })
// wx.redirectTo({ }
// url: '/packagePersonal/pages/boutiqueList/boutiqueList' // 获取订单截图
// }) _this.getOrderScreenShot()
}, },
fail: function (error) { fail: function (error) {
// wx.switchTab({ // wx.switchTab({
// url: '/pages/tab/index/index' // url: '/pages/tab/index/index'
// }) // })
console.log(error)
wx.showToast({ wx.showToast({
title: '支付失败', title: '支付失败',
icon: 'error' icon: 'error'
...@@ -129,6 +229,7 @@ Page( ...@@ -129,6 +229,7 @@ Page(
// 获取订单信息 // 获取订单信息
getScenInfo() { getScenInfo() {
util.showLoading('加载中...')
let id = this.data.sceneId let id = this.data.sceneId
console.log(this.data) console.log(this.data)
// console.log(); // console.log();
...@@ -156,13 +257,61 @@ Page( ...@@ -156,13 +257,61 @@ Page(
}) })
//util.showLoading('加载中...') //util.showLoading('加载中...')
console.log(op) console.log(op)
this.getInfo(op) this.getOrderDetail(op)
} }
} }
} }
) )
} }
},
getOrderDetail(item) {
console.log(item, 'item')
let { orderCode } = item
api
.getOrderDetail({
orderCode
})
.then(res => {
console.log(res, 'res')
let { code, data, errId, message } = res
// console.log(data, 'data')
// console.log(data.sceneType == 1);
// debugger
if (code == 0) {
this.setData({
sceneType: data.sceneType == 1
})
// 必须要订单 为待支付才能发起支付
if (data?.payOrder == null || data.payOrder.payStatus == 1) {
this.getInfo(item)
} else {
wx.showToast({
title: '非待支付订单',
icon: 'error'
})
}
} else if (errId == '-5003') {
wx.showToast({
title: message || '订单已失效',
icon: 'error'
})
} else {
wx.showToast({
title: '请求失败',
icon: 'error'
})
}
})
// ,
// res => {
// // else {
// // util.showToast('系统异常')
// // }
// }
// )
} }
}) // })
// } })
)
{ {
"usingComponents": {}, "usingComponents": {
},
"navigationBarTitleText": "支付" "navigationBarTitleText": "支付"
} }
\ No newline at end of file \ No newline at end of file
<!--支付--> <!-- 支付 -->
<view class="page"> <!-- wx:if="{{orderInfo}}" -->
<view class="success-Container" wx:if="{{paySuccess}}"> <block wx:if="{{paySuccess}}">
<!-- <view class="amountOfMoney">¥ {{payMoney}}</view> --> <view class="poster">
<view class="success-tips"> <image
<image class="successIcon" src="../../../images/successIcon.png" /> show-menu-by-longpress="true"
支付成功 class="posetrimg"
</view> mode="widthFix"
<view class="line" /> src="{{posterUrl}}" />
<view class="orderInfo">
<view class="label">收款主体</view>
<view class="info">深圳市嘀加智慧云服务有限公司</view>
</view>
<!-- <view class="orderInfo">
<view class="label">商户名称</view>
<view class="info">{{merchantName || shopMerchantName}}</view>
</view> -->
<view class="orderInfo">
<view class="label">支付订单号</view>
<view class="info">{{orderCode}}</view>
</view>
<view class="orderInfo">
<view class="label">支付时间</view>
<view class="info">{{dataTime}}</view>
</view>
</view> </view>
</view>
<auth-setting auth='{{authToast}}' type='{{authType}}' index />
\ No newline at end of file \ No newline at end of file
<view class="footerCon" wx:if="{{sceneType}}">
<view class="wxTips" >长按识别扫码领取质保卡</view>
<image bindlongpress="navWarrantyCard"
class="wxqrCon"
src="https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/minizhibaoka.png" />
<image class="logoIcon" src="../../../images/djLogin.png" />
</view>
</block>
<!-- <auth-setting auth='{{authToast}}' type='{{authType}}' /> -->
/* packagesPayment/pages/payment/index.wxss */ /* packagesPayment/pages/payment/index.wxss */
.success-Container { /* page {
padding: 100rpx 76rpx 0; padding: 20rpx;
text-align: center; } */
background-color: #fff;
height: 100vh;
}
.amountOfMoney {
font-size: 80rpx;
font-weight: 600;
}
.success-tips {
display: flex;
align-items: center;
justify-content: center;
font-size: 48rpx;
margin-bottom: 30rpx;
}
.successIcon {
width: 64rpx;
height: 64rpx;
margin-right: 30rpx;
}
.orderInfo {
display: flex;
justify-content: space-between;
}
.success-Container { .poster {
box-sizing: border-box; box-sizing: border-box;
display: flex; margin: 20rpx auto;
flex-direction: column; width: 710rpx;
/* justify-content: center; */ /* height: 964rpx; */
align-items: center; background: #FFFFFF;
} box-shadow: 0 4rpx 20rpx 0 #0000001a;
border-radius: 16rpx;
.success-Container .line {
height: 1px;
width: 100%;
margin: 28rpx 0;
background: #E5E5E5;
} }
.success-Container .orderInfo { .posetrimg {
width: 100%; width: 100%;
margin-bottom: 28rpx; /* height: 100%; */
}
.success-Container .label {
font-size: 30rpx;
color: #999;
}
.success-Container .info {
font-size: 30rpx;
color: #333;
flex: 1;
text-align: right;
max-width: 80%;
overflow: hidden;
text-overflow: ellipsis;
/* display: -webkit-box; */
white-space: nowrap;
} }
.footerCon { .footerCon {
margin-top: auto; box-sizing: border-box;
margin-bottom: 200rpx; width: 710rpx;
height: 558rpx;
background: #FFFFFF;
box-shadow: 0 4rpx 20rpx 0 #0000001a;
border-radius: 16rpx;
/* margin-top: auto; */
margin: auto auto 0rpx;
/* margin-bottom: 200rpx; */
padding: 44rpx 0 58rpx;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
...@@ -84,7 +43,7 @@ ...@@ -84,7 +43,7 @@
.wxqrCon { .wxqrCon {
width: 306rpx; width: 306rpx;
height: 305rpx; height: 305rpx;
margin: 12rpx 0 84rpx; margin: 16rpx 0 50rpx;
Object-fit: contain; Object-fit: contain;
} }
......
...@@ -4,7 +4,7 @@ Page({ ...@@ -4,7 +4,7 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
webpageUrl: '' webpageUrl: 'http://lexiangla.com/staff?company_from=f61c3d0c101f11ebb06e5254002f1020'
}, },
/** /**
...@@ -15,7 +15,7 @@ Page({ ...@@ -15,7 +15,7 @@ Page({
console.log(accountInfo, 'accountInfo') console.log(accountInfo, 'accountInfo')
this.setData({ this.setData({
// webpageUrl: accountInfo.miniProgram.envVersion == 'release' ? 'https://dj.glsx.com.cn/dj-car-boutique-work-wechat/#/' : 'http://192.168.1.178:8080/#/detail?cardCode=211027-2201AAA01' // webpageUrl: accountInfo.miniProgram.envVersion == 'release' ? 'https://dj.glsx.com.cn/dj-car-boutique-work-wechat/#/' : 'http://192.168.1.178:8080/#/detail?cardCode=211027-2201AAA01'
webpageUrl: accountInfo.miniProgram.envVersion == 'release' ? 'https://dj.glsx.com.cn/dj-car-boutique-work-wechat/#/' : 'https://frontend.test.glsx.com.cn/dj-car-boutique-work-wechat/#/' // webpageUrl: accountInfo.miniProgram.envVersion == 'release' ? 'https://dj.glsx.com.cn/dj-car-boutique-work-wechat/#/' : 'https://frontend.test.glsx.com.cn/dj-car-boutique-work-wechat/#/'
}) })
}, },
......
...@@ -3,9 +3,36 @@ import api from './request.js' ...@@ -3,9 +3,36 @@ import api from './request.js'
module.exports = { module.exports = {
/** 获取订单数据*/ /** 获取订单数据*/
GETORDERINFO: function (oParams, success, fail) { GETORDERINFO: function (oParams, success, fail) {
restapi.req('/web-dj-weapp/smartcarlife/goodsOrder/createWxPayOrder', oParams, {}, 'GET', 'json', 'text', success, fail) restapi.req('/web-dj-weapp/smartcarlife/goodsOrder/createWxPayOrderWithNotLogin', oParams, {}, 'GET', 'json', 'text', success, fail)
// restapi.req('/web-dj-weapp/smartcarlife/goodsOrder/createWxPayOrder', oParams, {}, 'GET', 'json', 'text', success, fail)
},
/** 精品交付单订单详情列表 */
// getBoutiqueOrderDetail(data, success, fail) {
// api.get('boutiquedelivery/order/getDetail', data, success, fail)
// },
// req(`/web-dj-weapp/${link}`, data, header, method, 'json', 'text',
/** 精品交付单订单详情列表 */
// getBoutiqueOrderDetail: function (params, success, fail) {
// restapi.req(
// '/web-dj-weapp/boutiquedelivery/order/getDetail',
// // JSON.stringify(code),
// params, {},'GET', 'json', 'text', success,fail
// )
// },
getDetailByOrderCode(params, success, fail) {
// api.get('smartcarlife/goodsOrder/getDetailByOrderCode', data, success)
restapi.req(
'/web-dj-weapp/smartcarlife/goodsOrder/getDetailByOrderCode',
// JSON.stringify(code),
params,
{},
'GET',
'json',
'text',
success,
fail
)
}, },
/** /**
* 根据场景id获取场景值 * 根据场景id获取场景值
*/ */
...@@ -88,5 +115,13 @@ module.exports = { ...@@ -88,5 +115,13 @@ module.exports = {
/** 获取用户协议配置 */ /** 获取用户协议配置 */
getTitleByModule(data) { getTitleByModule(data) {
return api.post('dj.api.smartcarlife.privacyAgreement.getTitleByModule', data) return api.post('dj.api.smartcarlife.privacyAgreement.getTitleByModule', data)
},
/** 订单截图 */
orderScreenShot(data) {
return api.post('dj.api.smartcarlife.common.screenShot', data)
},
/** 新订单详情 */
getOrderDetail(data) {
return api.post('dj.api.smartcarlife.order.detail', data)
} }
} }
...@@ -116,9 +116,6 @@ module.exports = { ...@@ -116,9 +116,6 @@ module.exports = {
restapi.req( restapi.req(
'/web-dj-weapp/smartcarlife/goodsOrder/queryPayOrderStatus', '/web-dj-weapp/smartcarlife/goodsOrder/queryPayOrderStatus',
params, params,
// {
// 'content-type': 'application/x-www-form-urlencoded'
// },
{ {
'content-type': 'application/json' 'content-type': 'application/json'
}, },
......
...@@ -40,7 +40,8 @@ ...@@ -40,7 +40,8 @@
"minifyWXML": true, "minifyWXML": true,
"showES6CompileOption": false, "showES6CompileOption": false,
"useCompilerPlugins": false, "useCompilerPlugins": false,
"ignoreUploadUnusedFiles": true "ignoreUploadUnusedFiles": true,
"condition": false
}, },
"compileType": "miniprogram", "compileType": "miniprogram",
"libVersion": "2.8.3", "libVersion": "2.8.3",
......
...@@ -243,7 +243,7 @@ ...@@ -243,7 +243,7 @@
{ {
"name": "支付", "name": "支付",
"pathName": "packagesPayment/pages/payment/index", "pathName": "packagesPayment/pages/payment/index",
"query": "sceneId='sceneId=10683'", "query": "",
"launchMode": "default", "launchMode": "default",
"scene": null "scene": null
}, },
...@@ -279,5 +279,6 @@ ...@@ -279,5 +279,6 @@
} }
}, },
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "dj-car-weapp-smartshop" "projectname": "dj-car-weapp-smartshop",
"libVersion": "2.24.4"
} }
\ No newline at end of file \ No newline at end of file
// export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/store-assistant/'
import getAppId from '~/utils/utils_wx'
import util from '~/utils/util'
export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/'
// 缓存get方法为空的默认指定值
export const DEFAULT_GET_STORAGEKEY = ['sessionId', 'merchantId', 'userInfo']
export const appId = getAppId.getAppId()
// 缓存get方法key的对应才映射值
export const STORAGE_OBJECTkEY = {
DEFAULT_GET_STORAGEKEY,
sessionId: 'sessionId',
userInfo: 'userInfo',
system_info: 'system_info',
app_title: 'appTitle',
auto_login_object: 'auto_login_object',
address_info: 'address_info',
wx_user_info: 'wx_user_info',
isVIP: 'isVIP',
edjurl: 'edjurl',
isNeedShowModal: 'isNeedShowModal',
bindInfo: 'bindInfo',
isShowPreModal: 'isShowPreModal',
unauthorized: 'unauthorized',
activityId: 'activityId',
shareStaff: 'shareStaff',
miaoshatrack: 'miaoshatrack',
lastCouponIds: 'lastCouponIds',
merchant_info: 'merchant_info',
refresh_oil_oage: 'refresh_oil_oage',
shareStaffTracker: 'shareStaffTracker',
srcm_shopmall_merchant_id: 'srcm_shopmall_merchant_id',
srcm_shopmall_city_list: 'srcm_shopmall_city_list',
srcm_shopmall_brand_list: 'srcm_shopmall_brand_list',
newCarBrandList: 'newCarBrandList',
scrm_shopmall_car_brand_list: 'scrm_shopmall_car_brand_list',
srcm_shopmall_user_info: 'srcm_shopmall_user_info',
scrm_shopmall_sessionId: 'scrm_shopmall_sessionId',
closeMask: 'closeMask',
activity_options: 'activity_options',
closePYQTip: 'closePYQTip',
user_profile: 'user_profile',
srcm_shopmall_customer_id: 'srcm_shopmall_customer_id',
mock_data: 'mock_data'
}
export const IMG_VERSION = async () => {
const accountInfo = await util.getMockData()
return accountInfo?.version || Date.now()
}
\ No newline at end of file \ No newline at end of file
/** // /**
* // *
0本地 // 0本地
1开发 // 1开发
2测试 // 2测试
3生产环境 // 3生产环境
4预发布环境 // 4预发布环境
*/ // */
const accountInfo = wx.getAccountInfoSync() // const accountInfo = wx.getAccountInfoSync()
const systemInfo = wx.getSystemInfoSync() // const systemInfo = wx.getSystemInfoSync()
// console.log(systemInfo); // // console.log(systemInfo);
// console.log(accountInfo.miniProgram.envVersion) // // console.log(accountInfo.miniProgram.envVersion)
//手动控制体验版环境的请求 true就依据下面index false就默认为2 // //手动控制体验版环境的请求 true就依据下面index false就默认为2
const manual = false // const manual = false
const release = false // const release = false
let index =3 // let index =1
// 判断小程序环境 // // 判断小程序环境
// develop:开发版(正常开发工具,测试时) // // develop:开发版(正常开发工具,测试时)
// trial:体验版 // // trial:体验版
// release:正式版 // // release:正式版
// console.log( systemInfo.platform); // // console.log( systemInfo.platform);
// console.log(accountInfo.miniProgram.envVersion); // // console.log(accountInfo.miniProgram.envVersion);
if (systemInfo.platform != 'devtools') { // if (systemInfo.platform != 'devtools') {
switch (accountInfo.miniProgram.envVersion) { // switch (accountInfo.miniProgram.envVersion) {
case 'develop': // case 'develop':
// this.globalData.url = 'http://192.168.0.252:3000/api'; // // // this.globalData.url = 'http://192.168.0.252:3000/api'; //
break // break
case 'trial': // case 'trial':
index = manual ? index : 2 // index = manual ? index : 2
break // break
case 'release': // case 'release':
index = release ? index : 3 // index = release ? index : 3
break // break
default: // default:
index = 3 // index = 3
break // break
} // }
} // }
import { envIndex } from '~/config'
let index = envIndex
const domain_items = { const domain_items = {
ip: 'http://192.168.3.181:9182', ip: 'http://192.168.3.181:9182',
dev: 'https://dj.dev.glsx.com.cn', dev: 'https://dj.dev.glsx.com.cn',
...@@ -49,7 +51,6 @@ const domain_items = { ...@@ -49,7 +51,6 @@ const domain_items = {
const domain= domain_items[target[index]] const domain= domain_items[target[index]]
const app = getApp()
/** /**
* 通用请求 * 通用请求
......
import $router from '../router/index'
/**
* 微信校验通知类工具封装
*/
const tipsObj = {
phone: {
icon: 'error',
title: '请输入手机号'
},
username: {
icon: 'error',
title: '请输入用户名'
},
password: {
icon: 'error',
title: '请输入密码'
}
}
/**
* 禁止滑动
*/
const noScroll = () => {}
/**设置粘贴板内容 */
const setCopyData = (data, callBack) => {
wx.setClipboardData({
data: data,
success(res) {
if (callBack && typeof callBack === 'function') callBack(res)
}
})
}
/** 获取小程序 appId */
const getAppId = () => {
return wx.getAccountInfoSync().miniProgram.appId
}
/**
* 防止重复点击
*/
const showLoading = (title = '') => {
if (wx.showLoading) {
// 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理
wx.showLoading({
title,
mask: true
})
} else {
// 低版本采用Toast兼容处理并将时间设为20秒以免自动消失
wx.showToast({
title,
icon: 'loading',
mask: true,
duration: 20000
})
}
}
const hideLoading = () => {
if (wx.hideLoading) {
// 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理
wx.hideLoading()
} else {
wx.hideToast()
}
}
const showToast = val => {
let obj = {}
if (val && typeof val === 'object') {
obj = val
} else {
obj.title = String(val)
obj.icon = 'none'
}
return wx.showToast(obj)
}
/**
*
* @param {* string | object} name 信息名称
* @param {* object | null} [params] 信息名称参数
*/
const wxShowToast = (name, params) => {
if (arguments.length == 2) {
wx.showToast({
title: tipsObj[name]['title'],
icon: tipsObj[name]['icon'],
...params
})
} else {
wx.showToast({
...params
})
}
}
/**获取设备信息 */
const getSystemInfo = callBack => {
wx.getSystemInfo({
success(res) {
callBack(res)
},
fail(err) {
callBack(err)
}
})
}
/**拨打电话 */
const phoneCall = phoneNumber => {
wx.makePhoneCall({
phoneNumber: `${phoneNumber}`
})
}
/**查看大图 */
const previewImage = params => {
wx.previewImage(params)
}
/**是否全面屏 */
const isFullSucreen = isComponents => {
const thisPage = $router.getPageInstance()
const routerList = $router.getRouterList()
const router = routerList.find(item => item.url === `/${thisPage.route}`)
let key = `${router.url.replace('/', '')}.html`
let val = false
if (__wxConfig && __wxConfig.page && __wxConfig.page[key]) {
let {
navigationStyle
} = __wxConfig.page[key].window
wx.getSystemInfo({
success(res) {
if (res.platform != 'android') {
let {
statusBarHeight,
screenHeight,
windowHeight
} = res
if (navigationStyle && navigationStyle == 'custom') {
windowHeight = windowHeight - thisPage.data.navHeight || 0
}
//兼容自定义标题
val = router.isTab ? screenHeight - windowHeight - statusBarHeight - 32 > 72 : screenHeight - windowHeight > 72
if (isComponents) val = screenHeight - windowHeight > 72
}
},
fail(err) {
return false
}
})
}
return val
}
/**获取节点信息
* name(id获取class)
* callBack 回调函数
* isComponents是否在组件
*/
const getViewInfo = (name, callBack, isComponents) => {
const query = !isComponents ? wx.createSelectorQuery() : wx.createSelectorQuery().in(isComponents)
query
.select(name)
.boundingClientRect(res => {
callBack(res)
})
.exec()
}
/**触底加载 */
const onReachBottom = (obj, callBack) => {
let _this = $router.getPageInstance()
let {
pageNum,
total,
pageSize,
nothing
} = obj
if (!total && !pageNum) {
console.error('total&&pageNum为必传')
return
}
if (!pageSize) pageSize = 10
if (!nothing) nothing = 'nothing'
if (Math.ceil(total / pageSize) > pageNum) {
_this.setData({
pageNum: pageNum + 1
})
callBack()
} else {
_this.setData({
[nothing]: true
})
}
}
const wxApi = {
previewImage,
getSystemInfo,
showLoading,
hideLoading,
setCopyData,
showToast,
phoneCall,
noScroll,
wxShowToast,
getAppId,
isFullSucreen,
getViewInfo,
onReachBottom
}
export default wxApi
\ No newline at end of file \ 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!