Commit 5fd2a3e6 by 张立顺

功能开发中

1 parent 266cd5af
// 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,
} = 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 (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'
}
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
})
textList.push({
text: orderNumber || '',
x: labelX - 1,
y: 54,
color: '#282829',
fontSize,
textBaseline
})
}
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)
}
}
})
\ No newline at end of file \ No newline at end of file
{
"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
...@@ -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,9 +3,8 @@ const filter = require('../../../utils/filter.js') ...@@ -3,9 +3,8 @@ 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( Page({
// { // filter.identityFilter({
filter.identityFilter({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
...@@ -14,7 +13,25 @@ Page( ...@@ -14,7 +13,25 @@ Page(
authType: true, // 授权类型(true:授权用户信息;false:授权手机号) authType: true, // 授权类型(true:授权用户信息;false:授权手机号)
sceneId: '', sceneId: '',
ajaxing: false, ajaxing: false,
paySuccess: false paySuccess: false,
orderInfo: {
userName: 2222,
plateNo: 2222,
vehicleBrandName: 2222,
vehicleSubBrandName: 2222,
vehicleSeriesName: 2222,
vehicleShapeName: 2222,
goodsName: 2222,
createdDate: 2222,
payPrice: 2222,
orderStatus: 1,
formContentFirst: 2222,
formContentSecond: 2222,
formDescribeFirst: 2222,
formDescribeSecond: 2222,
orderNumber: 2222,
goodsNumber: 2222
}
// paySuccess: true // paySuccess: true
}, },
...@@ -30,6 +47,8 @@ Page( ...@@ -30,6 +47,8 @@ Page(
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
// 开发用
this.getOrderDetail()
// options.scene = 'sceneId=10689' // options.scene = 'sceneId=10689'
// let options = { // let options = {
...@@ -66,7 +85,28 @@ Page( ...@@ -66,7 +85,28 @@ Page(
ajaxing: false ajaxing: false
}) })
}, },
getOrderDetail() {
api.getDetailByOrderCode(
{ orderCode: '230331143020741' },
res => {
console.log(res, 'result')
this.setData({
orderInfo: res.data
})
// this.render(orderCode, res, true, fromMenu);
},
error => {
this.showError()
console.log(error, 'getDetail request error')
}
)
// api.getBoutiqueOrderDetail({orderCode:'230331143020741'}).then((result) => {
// }).catch((err) => {
// });
},
// 获取订单信息 // 获取订单信息
getInfo: function (row) { getInfo: function (row) {
let _this = this let _this = this
...@@ -164,6 +204,5 @@ Page( ...@@ -164,6 +204,5 @@ Page(
) )
} }
} }
// })
}) })
// }
)
{ {
"usingComponents": {}, "usingComponents": {
"create-order-img": "../../components/createImage/index"
},
"navigationBarTitleText": "支付" "navigationBarTitleText": "支付"
} }
\ No newline at end of file \ No newline at end of file
<!--支付--> <!-- 支付 -->
<!-- wx:if="{{orderInfo}}" -->
<!-- <create-order-img orderInfo="{{orderInfo}}" custom-class="img" /> -->
<view class="page"> <view class="page">
<view class="success-Container" wx:if="{{paySuccess}}"> <view class="success-Container" wx:if="{{paySuccess}}">
<!-- <view class="amountOfMoney">¥ {{payMoney}}</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" />
支付成功 支付成功
</view> </view>
<view class="line" /> <view class="line" />
<view class="orderInfo"> <view class="orderInfo">
<view class="label">收款主体</view> <view class="label">收款主体</view>
<view class="info">深圳市嘀加智慧云服务有限公司</view> <view class="info">深圳市嘀加智慧云服务有限公司</view>
</view> </view>
<!-- <view class="orderInfo"> <!-- <view class="orderInfo">
<view class="label">商户名称</view> <view class="label">商户名称</view>
<view class="info">{{merchantName || shopMerchantName}}</view> <view class="info">{{merchantName || shopMerchantName}}</view>
</view> --> </view> -->
<view class="orderInfo"> <view class="orderInfo">
<view class="label">支付订单号</view> <view class="label">支付订单号</view>
<view class="info">{{orderCode}}</view> <view class="info">{{orderCode}}</view>
</view> </view>
<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> </view>
</view>
</view> </view>
<auth-setting auth='{{authToast}}' type='{{authType}}' index />
\ No newline at end of file \ No newline at end of file
<auth-setting auth='{{authToast}}' type='{{authType}}' index />
\ No newline at end of file \ No newline at end of file
/* packagesPayment/pages/payment/index.wxss */ /* packagesPayment/pages/payment/index.wxss */
.img {
width: 686rpx;
}
.success-Container { .success-Container {
padding: 100rpx 76rpx 0; padding: 100rpx 76rpx 0;
text-align: center; text-align: center;
......
...@@ -5,7 +5,33 @@ module.exports = { ...@@ -5,7 +5,33 @@ 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/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获取场景值
*/ */
......
...@@ -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
}, },
......
// 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
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!