初始化
This commit is contained in:
35
common/js/WXBizDataCrypt.js
Normal file
35
common/js/WXBizDataCrypt.js
Normal file
@@ -0,0 +1,35 @@
|
||||
var crypto = require('crypto')
|
||||
|
||||
function WXBizDataCrypt(appId, sessionKey) {
|
||||
this.appId = appId
|
||||
this.sessionKey = sessionKey
|
||||
}
|
||||
|
||||
WXBizDataCrypt.prototype.decryptData = function (encryptedData, iv) {
|
||||
// base64 decode
|
||||
var sessionKey = new Buffer(this.sessionKey, 'base64')
|
||||
encryptedData = new Buffer(encryptedData, 'base64')
|
||||
iv = new Buffer(iv, 'base64')
|
||||
|
||||
try {
|
||||
// 解密
|
||||
var decipher = crypto.createDecipheriv('aes-128-cbc', sessionKey, iv)
|
||||
// 设置自动 padding 为 true,删除填充补位
|
||||
decipher.setAutoPadding(true)
|
||||
var decoded = decipher.update(encryptedData, 'binary', 'utf8')
|
||||
decoded += decipher.final('utf8')
|
||||
|
||||
decoded = JSON.parse(decoded)
|
||||
|
||||
} catch (err) {
|
||||
throw new Error('Illegal Buffer')
|
||||
}
|
||||
|
||||
if (decoded.watermark.appid !== this.appId) {
|
||||
throw new Error('Illegal Buffer')
|
||||
}
|
||||
|
||||
return decoded
|
||||
}
|
||||
|
||||
module.exports = WXBizDataCrypt
|
||||
224
common/js/api.js
Normal file
224
common/js/api.js
Normal file
@@ -0,0 +1,224 @@
|
||||
export default {
|
||||
userlogin(data) { //登录
|
||||
return uni.api.post("/user/login", data);
|
||||
},
|
||||
classificationbottomnavigation(data) { //底部导航
|
||||
return uni.api.post("/classification/bottomnavigation", data);
|
||||
},
|
||||
usermy(data) { //我的
|
||||
return uni.api.post("/my", data);
|
||||
},
|
||||
smssend(data) { //发送验证码
|
||||
return uni.api.post("/sms/send", data);
|
||||
},
|
||||
userbindingphone(data) { //绑定手机号
|
||||
return uni.api.post("/user/bindingphone", data);
|
||||
},
|
||||
useruserinfo(data) { //个人资料
|
||||
return uni.api.post("/user/userinfo", data);
|
||||
},
|
||||
useruserinfoedit(data) { //个人资料修改
|
||||
return uni.api.post("/user/userinfoedit", data);
|
||||
},
|
||||
reservationclassyy(data) { //预约分类
|
||||
return uni.api.post("/reservation/classyy", data);
|
||||
},
|
||||
reservationlist(data) { //预约列表
|
||||
return uni.api.post("/reservation/list", data, false);
|
||||
},
|
||||
indexworksdetail(data) { //作品详情
|
||||
return uni.api.post("/index/worksdetail", data);
|
||||
},
|
||||
indexworks(data) { //作品
|
||||
return uni.api.post("/index/works", data);
|
||||
},
|
||||
indexappclassindex(data) { //店铺详情
|
||||
return uni.api.post("/index/appclassindex", data);
|
||||
},
|
||||
indexnewappclassindex(data) { //新店铺详情
|
||||
return uni.api.post("/index/newappclassindex", data);
|
||||
},
|
||||
positionindex(data) { //首页
|
||||
return uni.api.post("/index", data, false);
|
||||
},
|
||||
reservationdetail(data) { //服务详情
|
||||
return uni.api.post("/reservation/detail", data, false);
|
||||
},
|
||||
okmakenowreservation(data) { //确认预约页面
|
||||
return uni.api.post("/reservation/okmakenow", data);
|
||||
},
|
||||
reservationmakenowsub(data) { //确认支付
|
||||
return uni.api.post("/reservation/makenowsub", data, false, 1);
|
||||
},
|
||||
paygetpayparams(data) { //获取支付参数
|
||||
return uni.api.post("/pay/getpayparams", data, false, 1);
|
||||
},
|
||||
payorderstatus(data) { //获取支付状态
|
||||
return uni.api.post("/pay/orderstatus", data);
|
||||
},
|
||||
orderlist(data) { //订单列表
|
||||
return uni.api.post("/order/list", data);
|
||||
},
|
||||
orderorderdetail(data) { //订单详情
|
||||
return uni.api.post("/order/orderdetail", data);
|
||||
},
|
||||
orderordercancel(data) { //取消订单
|
||||
return uni.api.post("/order/ordercancel", data);
|
||||
},
|
||||
orderorderdelete(data) { //取消订单订单
|
||||
return uni.api.post("/order/orderdelete", data);
|
||||
},
|
||||
orderorderrefund(data) { //申请/修改退款
|
||||
return uni.api.post("/order/orderrefund", data);
|
||||
},
|
||||
orderrefunddetail(data) { //退款详情
|
||||
return uni.api.post("/order/orderrefunddetail", data);
|
||||
},
|
||||
userusercarlist(data) { //会员卡列表
|
||||
return uni.api.post("/user/usercarlist", data);
|
||||
},
|
||||
userbalancerechange(data) { //余额卡充值金额
|
||||
return uni.api.post("/user/balancerechange", data);
|
||||
},
|
||||
userreceivebalancecar(data) { //领取会员卡
|
||||
return uni.api.post("/user/receivebalancecar", data);
|
||||
},
|
||||
orderorderrefundcancel(data) { //取消退款
|
||||
return uni.api.post("/order/orderrefundcancel", data);
|
||||
},
|
||||
useruserpolicy(data) { //
|
||||
return uni.api.post("/user/userpolicy", data);
|
||||
},
|
||||
userbalancerechangesub(data) { //取消退款
|
||||
return uni.api.post("/user/balancerechangesub", data);
|
||||
},
|
||||
usergetwechatphone(data) { //微信获取手机号
|
||||
return uni.api.post("/user/getwechatphone", data);
|
||||
},
|
||||
userputopenid(data) { //openid
|
||||
return uni.api.post("/user/putopenid", data);
|
||||
},
|
||||
reservationmakenow(data) { //可预约时间
|
||||
return uni.api.post("/reservation/makenow", data);
|
||||
},
|
||||
reservationattendantavailable(data) { //有空服务员
|
||||
return uni.api.post("/reservation/attendantavailable", data);
|
||||
},
|
||||
uservippassword(data) { //设置安全密码
|
||||
return uni.api.post("/user/vippassword", data, true);
|
||||
},
|
||||
reservationdirectorder(data) { //直接下单
|
||||
return uni.api.post("/reservation/directorder", data);
|
||||
},
|
||||
reservationorderecho(data) { //订单回显
|
||||
return uni.api.post("/reservation/orderecho", data);
|
||||
},
|
||||
reservationvipdetail(data) { //店铺会员卡详情
|
||||
return uni.api.post("/reservation/vipdetail", data);
|
||||
},
|
||||
useropenuserseccrd(data) { //开通次卡
|
||||
return uni.api.post("/user/openuserseccrd", data);
|
||||
},
|
||||
useruserbalance(data) { //用户余额卡信息
|
||||
return uni.api.post("/user/userbalance", data);
|
||||
},
|
||||
reservationdesignerviewtime(data) { //设计师可预约时间
|
||||
return uni.api.post("/reservation/designerviewtime", data);
|
||||
},
|
||||
reservationpeopleinfo(data) { //服务员详情
|
||||
return uni.api.post("/reservation/peopleinfo", data);
|
||||
},
|
||||
reservationpaythebill(data) { //买单页面
|
||||
return uni.api.post("/reservation/paythebill", data);
|
||||
},
|
||||
reservationpaythebillsub(data) { //买单付款
|
||||
return uni.api.post("/reservation/paythebillsub", data);
|
||||
},
|
||||
shoppingindex(data) { //商城首页
|
||||
return uni.api.post("/shopping/index", data);
|
||||
},
|
||||
shoppingindexgoodsclass(data) { //商品分类
|
||||
return uni.api.post("/shopping/index/goodsclass", data);
|
||||
},
|
||||
shoppingindexgoodsgoodsdetail(data) { //商品详情
|
||||
return uni.api.post("/shopping/goods/goodsdetail", data);
|
||||
},
|
||||
shoppingindexgoodindexsaddcar(data) { //添加购物车
|
||||
return uni.api.post("/shopping/index/addcar",data);
|
||||
},
|
||||
shoppingindexgoodindexcarlistr(data) { //购物车列表
|
||||
return uni.api.post("/shopping/index/carlist",data,false);
|
||||
},
|
||||
shoppingindexgoodindexcardelcarr(data) { //删除购物车
|
||||
return uni.api.post("/shopping/index/delcar",data);
|
||||
},
|
||||
shoppingindexgoodindexcareditcar(data) { //编辑购物车
|
||||
return uni.api.post("/shopping/index/editcar",data);
|
||||
},
|
||||
shoppingindexgoodindexoforders(data) { //结算/确认订单
|
||||
return uni.api.post("/shopping/index/oforders",data);
|
||||
},
|
||||
shoppingindexgoodindexsuborder(data) { //提交订单
|
||||
return uni.api.post("/shopping/index/suborder",data,false, 1);
|
||||
},
|
||||
shoppingindexgoodindexgetpayparams(data) { //获取支付参数
|
||||
return uni.api.post("/shopping/index/getpayparams", data, false, 1);
|
||||
},
|
||||
usermyaddresslist(data) { //我的地址列表
|
||||
return uni.api.post("/user/myaddresslist", data);
|
||||
},
|
||||
usereditaddress(data) { //编辑/添加地址
|
||||
return uni.api.post("/user/editaddress", data);
|
||||
},
|
||||
useredeleteaddress(data) { //删除地址
|
||||
return uni.api.post("/user/deleteaddress", data);
|
||||
},
|
||||
usereaddressshow(data) { //地址回显
|
||||
return uni.api.post("/user/addressshow", data);
|
||||
},
|
||||
shoppingorderlist(data) { //商城订单列表
|
||||
return uni.api.post("/shopping/order/list", data);
|
||||
},
|
||||
shoppingorderordercancel(data) { //商城订单取消
|
||||
return uni.api.post("/shopping/order/ordercancel", data);
|
||||
},
|
||||
shoppingorderorderorderdelete(data) { //商城删除订单
|
||||
return uni.api.post("/shopping/order/orderdelete", data);
|
||||
},
|
||||
shoppingorderorderororderrefund(data) { //商城申请/修改退款
|
||||
return uni.api.post("/shopping/order/orderrefund", data);
|
||||
},
|
||||
shoppingorderoorderdetail(data) { //商城订单详情
|
||||
return uni.api.post("/shopping/order/orderdetail", data);
|
||||
},
|
||||
shoppingorderorderrefunddetail(data) { //商城退款详情
|
||||
return uni.api.post("/shopping/order/orderrefunddetail", data);
|
||||
},
|
||||
shoppingorderorderorderrefundcancel(data) { //商城取消退款
|
||||
return uni.api.post("/shopping/order/orderrefundcancel", data);
|
||||
},
|
||||
shoppingorderordershoppingorderstatus(data) { //商城支付状态查询
|
||||
return uni.api.post("/shopping/user/shoppingorderstatus", data);
|
||||
},
|
||||
shoppinggoodsproductspec(data) { //商品规格
|
||||
return uni.api.post("/shopping/goods/productspec", data);
|
||||
},
|
||||
shoppingbuyingspeciallist(data) { //每日特价
|
||||
return uni.api.post("/shopping//buying/speciallist",data);
|
||||
},
|
||||
reservationhoteldetial(data) { //酒店详情
|
||||
return uni.api.post("/reservation/hoteldetial",data);
|
||||
},
|
||||
reservationhotelconfirm(data) { //确认支付页面
|
||||
return uni.api.post("/reservation/hotelconfirm",data);
|
||||
},
|
||||
reservationhotelsub(data) { //立即提交
|
||||
return uni.api.post("/reservation/hotelsub",data);
|
||||
},
|
||||
reservationhotelgetpay(data) { //获取支付参数
|
||||
return uni.api.post("/reservation/hotelgetpay",data);
|
||||
},
|
||||
payhotelorderstatus(data) { //获取支付参数
|
||||
return uni.api.post("/pay/hotelorderstatus",data);
|
||||
},
|
||||
}
|
||||
74
common/js/lange.js
Normal file
74
common/js/lange.js
Normal file
@@ -0,0 +1,74 @@
|
||||
const env = {
|
||||
aliyunServerURL: 'https://czg-oss.oss-cn-beijing.aliyuncs.com',
|
||||
accessid: 'LTAI5tMLHwnM1zYYAFuRa1fK',
|
||||
AccessKeySecret: 'jS1h2STq1vcODczDNFQkjcU6ODyYAj',
|
||||
timeout: 100000
|
||||
}
|
||||
|
||||
const Base64 = require('./Base64.js');
|
||||
|
||||
require('./hmac.js');
|
||||
require('./sha1.js');
|
||||
const Crypto = require('./crypto.js');
|
||||
|
||||
|
||||
const uploadFile = function(filePath, key = new Date().getTime()) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// const aliyunFileKey = `${new Date().getTime()}_${userId}`;
|
||||
const aliyunServerURL = env.aliyunServerURL;
|
||||
const accessid = env.accessid;
|
||||
const policyBase64 = getPolicyBase64();
|
||||
const signature = getSignature(policyBase64);
|
||||
|
||||
wx.uploadFile({
|
||||
url: aliyunServerURL, //仅为示例,非真实的接口地址
|
||||
filePath: filePath,
|
||||
name: 'file',
|
||||
formData: {
|
||||
'key': 'headportrait/' + key,
|
||||
'OSSAccessKeyId': accessid,
|
||||
'policy': policyBase64,
|
||||
'Signature': signature,
|
||||
'success_action_status': '200',
|
||||
},
|
||||
success: function(res) {
|
||||
if (res.statusCode != 200) {
|
||||
reject('上传错误:' + JSON.stringify(res))
|
||||
return;
|
||||
}
|
||||
resolve(`https://czh5.sxczgkj.cn/headportrait/${key}`)
|
||||
},
|
||||
fail: function(err) {
|
||||
reject('上传错误:' + JSON.stringify(err))
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const getPolicyBase64 = function() {
|
||||
let date = new Date();
|
||||
date.setHours(date.getHours() + env.timeout);
|
||||
let srcT = date.toISOString();
|
||||
const policyText = {
|
||||
"expiration": srcT, //设置该Policy的失效时间,超过这个失效时间之后,就没有办法通过这个policy上传文件了 指定了Post请求必须发生在2020年01月01日12点之前("2020-01-01T12:00:00.000Z")。
|
||||
"conditions": [
|
||||
["content-length-range", 0, 20 * 1024 * 1024] // 设置上传文件的大小限制,1048576000=1000mb
|
||||
]
|
||||
};
|
||||
|
||||
const policyBase64 = Base64.encode(JSON.stringify(policyText));
|
||||
return policyBase64;
|
||||
}
|
||||
|
||||
const getSignature = function(policyBase64) {
|
||||
const accesskey = env.AccessKeySecret;
|
||||
|
||||
const bytes = Crypto.HMAC(Crypto.SHA1, policyBase64, accesskey, {
|
||||
asBytes: true
|
||||
});
|
||||
const signature = Crypto.util.bytesToBase64(bytes);
|
||||
|
||||
return signature;
|
||||
}
|
||||
|
||||
module.exports = uploadFile;
|
||||
1437
common/js/uqrCode.js
Normal file
1437
common/js/uqrCode.js
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user