Commit 35ffc0a6 by 张立顺

配置修改

1 parent 62eebaad
import api from './request.js'
// import api from './request.js'
const api = wx.$request
module.exports = {
/**企业微信登录 */
login(data) {
......
/**
*
0本地
1开发
2测试
3生产环境
*/
const accountInfo = wx.getAccountInfoSync()
const systemInfo = wx.getSystemInfoSync()
// console.log(systemInfo);
// console.log(accountInfo.miniProgram.envVersion)
//手动控制体验版环境的请求 true就依据下面index false就默认为2
const manual = false
const release = false
let index = 2
// 判断小程序环境
// develop:开发版(正常开发工具,测试时)
// trial:体验版
// release:正式版
// console.log( systemInfo.platform);
// console.log(accountInfo.miniProgram.envVersion);
if (systemInfo.platform != 'devtools') {
switch (accountInfo.miniProgram.envVersion) {
case 'develop':
// this.globalData.url = 'http://192.168.0.252:3000/api'; //
break
case 'trial':
index = manual ? index : 2
break
case 'release':
index = release ? index : 3
break
default:
index = 3
break
}
}
// console.log(index);
const secretKey_items = {
ip: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637',
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
},
dev: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637',
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
},
uat: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637',
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
},
prod: {
appKey: 'd7ffc3346fc9a45bccaaa35300d59022',
secret: '4bc07f8868374c49a4661d603377e3106fc9a45bccaaa353'
},
preRelease: {
appKey: 'd7ffc3346fc9a45bccaaa35300d59022',
secret: '4bc07f8868374c49a4661d603377e3106fc9a45bccaaa353'
}
}
const domain_items = {
// ip: 'http://192.168.2.59:8292',
// ip: 'http://192.168.1.129:8392',
// ip: 'http://192.168.1.129:8292',
ip: 'http://192.168.1.165:8292',
// ip: 'http://192.168.2.3:8292',
dev: 'https://dj.dev.glsx.com.cn',
uat: 'https://dj.test.glsx.com.cn',
// uat: 'https://dj.beta.glsx.com.cn',
prod: 'https://dj.glsx.com.cn',
preRelease: 'https://dj.beta.glsx.com.cn'
}
const target = ['ip', 'dev', 'uat', 'prod', 'preRelease']
// console.log(domain_items[target[index]]);
module.exports = {
domain: domain_items[target[index]],
secretKey: secretKey_items[target[index]]
}
import environment from './environment.js'
import sha1 from './sha1.js'
const path = '/rop-dj-car-boutique/router'
import qs from './qs'
const sign = (params, secret, noSignAttr = []) => {
delete params.sign
var objStr = qs.stringify(params, {
arrayFormat: 'indices',
allowDots: true,
encodeValuesOnly: true
})
var objVal = objStr.split('&')
var realObj = {}
objVal.forEach(item => {
const idx = item.indexOf('=')
realObj[item.split('=')[0]] = decodeURIComponent(item.slice(idx + 1))
})
const keys = Object.keys(realObj).sort()
var str = []
var obj = null
for (const key in realObj) {
obj = realObj[key]
if (obj === null) {
obj = ''
} else if (typeof obj === 'object') {
obj = JSON.stringify(obj)
}
realObj[key] = obj
}
keys.forEach(e => {
!noSignAttr.includes(e) && str.push(e + realObj[e])
})
realObj.sign = sha1(secret + str.join('') + secret).toUpperCase()
return realObj
}
module.exports = {
...environment,
path,
sign
}
\ No newline at end of file
import { secretKey, domain, path, sign } from './http.js'
import util from '../utils/util.js'
/**接口 */
class Request {
get(method, data, noSignAttr) {
return this.request('GET', method, data, noSignAttr)
}
post(method, data, noSignAttr) {
return this.request('POST', method, data, noSignAttr)
}
request(RequestMethods, method, data, noSignAttr = []) {
let _this = this
return new Promise((resolve, reject) => {
wx.showNavigationBarLoading()
if (!data) data = {}
let header =
RequestMethods === 'POST'
? {
'content-type': 'application/x-www-form-urlencoded'
}
: {}
data = _this.getData(data, method, noSignAttr)
wx.request({
url: `${domain}${path}?method=${method}`,
data,
method: RequestMethods,
header,
dataType: 'json',
responseType: 'text',
success(response) {
/**业务代码 */
let {
data: { code, message },
data
} = response
// let thisPage = wx.$router.getPageInstance()
// // console.log(thisPage, 'thisPage')
// let { route, data: pageData } = thisPage
// if (pageData.shareQuery) {
// wx.$util.setStorageSync('shareQuery', {
// route,
// shareQuery: pageData.shareQuery
// })
// }
if (code == 20 || code == 21) {
wx.hideLoading()
wx.showModal({
title: '温馨提示',
content: '登录过期,请重新登录。',
showCancel: false,
confirmText: '去登录',
confirmColor: '#3582EE',
success(res) {
if (res.confirm) {
getApp().login(true)
}
}
})
} else if (code == -1) {
wx.showToast({
title: message || '网络请求失败',
icon: 'none'
})
resolve(data)
} else {
resolve(data)
}
},
fail(error) {
wx.hideLoading()
console.error(`接口异常:${domain}${path}?method=${method}`, error)
wx.showToast({
title: '系统异常',
icon: 'error'
})
reject(error)
// if (fail && typeof fail == 'function') {
// fail(error, reject)
// } else {
// }
},
complete() {
wx.stopPullDownRefresh()
wx.hideNavigationBarLoading()
}
})
})
}
getData(data, method, noSignAttr) {
let sessionId = util.getSessionId()
if (sessionId) data['sessionId'] = sessionId
data['v'] = '1.0.0'
data['method'] = method
data['format'] = 'json'
data['locale'] = 'zh_CN'
data['source'] = 'dj-wechat'
data['appKey'] = secretKey.appKey
let obj = sign(data, secretKey.secret, noSignAttr)
//data['sign'] = obj.sign;
return obj
}
}
export default new Request()
function encodeUTF8(s) {
var i, r = [], c, x;
for (i = 0; i < s.length; i++)
if ((c = s.charCodeAt(i)) < 0x80) r.push(c);
else if (c < 0x800) r.push(0xC0 + (c >> 6 & 0x1F), 0x80 + (c & 0x3F));
else {
if ((x = c ^ 0xD800) >> 10 == 0) //对四字节UTF-16转换为Unicode
c = (x << 10) + (s.charCodeAt(++i) ^ 0xDC00) + 0x10000,
r.push(0xF0 + (c >> 18 & 0x7), 0x80 + (c >> 12 & 0x3F));
else r.push(0xE0 + (c >> 12 & 0xF));
r.push(0x80 + (c >> 6 & 0x3F), 0x80 + (c & 0x3F));
};
return r;
}
// 字符串加密成 hex 字符串
function sha1(s) {
var data = new Uint8Array(encodeUTF8(s))
var i, j, t;
var l = ((data.length + 8) >>> 6 << 4) + 16, s = new Uint8Array(l << 2);
s.set(new Uint8Array(data.buffer)), s = new Uint32Array(s.buffer);
for (t = new DataView(s.buffer), i = 0; i < l; i++)s[i] = t.getUint32(i << 2);
s[data.length >> 2] |= 0x80 << (24 - (data.length & 3) * 8);
s[l - 1] = data.length << 3;
var w = [], f = [
function () { return m[1] & m[2] | ~m[1] & m[3]; },
function () { return m[1] ^ m[2] ^ m[3]; },
function () { return m[1] & m[2] | m[1] & m[3] | m[2] & m[3]; },
function () { return m[1] ^ m[2] ^ m[3]; }
], rol = function (n, c) { return n << c | n >>> (32 - c); },
k = [1518500249, 1859775393, -1894007588, -899497514],
m = [1732584193, -271733879, null, null, -1009589776];
m[2] = ~m[0], m[3] = ~m[1];
for (i = 0; i < s.length; i += 16) {
var o = m.slice(0);
for (j = 0; j < 80; j++)
w[j] = j < 16 ? s[i + j] : rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1),
t = rol(m[0], 5) + f[j / 20 | 0]() + m[4] + w[j] + k[j / 20 | 0] | 0,
m[1] = rol(m[1], 30), m.pop(), m.unshift(t);
for (j = 0; j < 5; j++)m[j] = m[j] + o[j] | 0;
};
t = new DataView(new Uint32Array(m).buffer);
for (var i = 0; i < 5; i++)m[i] = t.getUint32(i << 2);
var hex = Array.prototype.map.call(new Uint8Array(new Uint32Array(m).buffer), function (e) {
return (e < 16 ? "0" : "") + e.toString(16);
}).join("");
return hex;
}
module.exports = sha1
......@@ -5,9 +5,9 @@ sentryInit()
// 判断小程序是否需要更新
import getUpdateManager from './utils/lib/wxUpdateManager'
import request from './api/request.js'
// import request from './api/request.js'
import request from '~/utils/request/request.js'
import router from './router/index.js'
import api from './api/api.js'
import util from './utils/util.js'
import wxApi from './utils/utils_wx'
// 实例化对象存储
......@@ -28,21 +28,19 @@ App({
// 存储设备信息
setSystem_info()
let userInfo = util.getStorageSync('dj_boutique_user_info')
userInfo && checkYqdSuper(userInfo)
userInfo && checkYqdSuper(this.globalData, userInfo)
},
showModal(that, options) {
that.selectComponent('#modal').showModal(options)
},
onShow(options) {
let that = this
getUpdateManager()
let { query } = options
// 判断对象是否满足任意一个key
// console.log(query, ' query')
if (query && (query.scene || query.merchantId || query.type)) {
// 需要满
if (query.merchantId) {
// &&options.patch == 'tabIndex/pages/index/index'
let userInfo = util.getStorageSync('dj_boutique_user_info')
......@@ -56,130 +54,21 @@ App({
if (query.type) {
options.patch = 'tabWorkOrder/pages/createOrder/createOrder'
}
// tabIndex/pages/index/index?supplement=true
wx.$SCENE = options
}
// console.log(wx.$SCENE, ' wx.$SCENE')
},
login(relogin) {
// 清空多账号信息
if (relogin) {
// debugger
// 清空多账号信息
this.globalData.yqdInfo = {}
this.globalData.YQorderSetting = ''
util.removeStorage()
wx.$relogin = relogin
}
router.reLaunch('pages.wxLogin')
},
// checkYqdSuper(userInfo) {
// // console.log('app', userInfo)
// let merchantAccountType = userInfo.merchantAccountList.every(item => {
// return item == 6 || item == 8
// })
// // this.globalData.isYqdSuper = userInfo.userType == 2 && !userInfo.isSuper && merchantAccountType
// this.globalData.isYqdSuper = userInfo.userType != 2 && !userInfo.isSuper && merchantAccountType
// this.globalData.isStaff = userInfo.userType == 2 && !userInfo.isSuper && merchantAccountType
// },
// 获取园区店信息
getYQInfo(userInfo) {
return new Promise((resolve, reject) => {
// 如果有 直接返回
if (this.globalData.yqdInfo.merchantRange) {
return resolve(this.globalData.yqdInfo)
}
// getUserInfo
// 判断是否是多账号用户
let subIndex = 0
if (!userInfo.isSuper && userInfo.merchantType && userInfo.userType == 2) {
this.globalData.yqdInfo = {
subIndex,
merchantRange: [{ merchantName: userInfo.merchantName }]
}
// this.setData({
// merchantRange: [{ merchantName: userInfo.merchantName }]
// })
// return
resolve(this.globalData.yqdInfo)
} else {
let all = {
merchantName: '全部'
}
api
.getYQList()
.then(res => {
// console.log(res)
let { code, data } = res
if (code == 0) {
let arr = []
if (data.length > 1) {
if (userInfo.merchantId != userInfo.subLoginUser.merchantId) {
data.map((e, index) => {
if (e.merchantId == userInfo.subLoginUser.merchantId) subIndex = index + 1
})
}
arr = [all, ...data]
} else {
arr = [
{
merchantName: userInfo.merchantName
}
]
}
this.globalData.yqdInfo = {
merchantRange: arr,
subIndex
}
// this.checkSeverType(userInfo)
resolve(this.globalData.yqdInfo)
}
})
.catch(error => {
console.log(error)
})
}
})
},
getYQorderInfo() {
return new Promise((resolve, reject) => {
// 如果有 直接返回
// console.log(this.globalData.YQorderSetting, 'this.globalData.YQorderSetting')
if (this.globalData.YQorderSetting) {
return resolve(this.globalData.YQorderSetting)
} else {
let userInfo = util.getUserInfo()
if (!userInfo) this.login(true)
let { merchantId, merchantName } = userInfo.subLoginUser
api
.getMerchantRecordingSettings({
merchantId,
merchantName
})
.then(res => {
// console.log(res)
let { code, data } = res
if (code == 0) {
// 过滤园区店是否需要屏蔽手机号选项
let filterYqPhoneConfig = JSON.parse(data.yqPhoneConfig)
// console.log(filterYqPhoneConfig)
data.yqPhoneConfig = filterYqPhoneConfig.find(item => item.yqMerchantId == merchantId)?.shopMerchantPhoneList || false
// console.log(data)
this.globalData.YQorderSetting = data
// this.checkSeverType(userInfo)
resolve(this.globalData.YQorderSetting)
}
})
.catch(error => {
console.log(error)
})
}
})
},
globalData: {
systemInfo: {},
statusBarHeight: wx.getSystemInfoSync()['statusBarHeight'], // 头部导航栏的高度
......@@ -188,6 +77,5 @@ App({
isYqdSuper: true,
isStaff: false,
YQorderSetting: ''
// refresh: false
}
})
// components/switchPopup/switchPopup.js
const app = getApp()
import api from '../../api/api'
import api from '~/api/api'
import { getYQorderInfo } from '~/store/index'
Component({
/**
* 组件的属性列表
......@@ -61,8 +62,8 @@ Component({
attached: function () {
// console.log(app.globalData.isYqdSuper)
console.log(this.data.isYqdSuper)
app
.getYQorderInfo()
// app .
getYQorderInfo()
.then(merchantSettingInfo => {
// console.log(merchantSettingInfo)
this.setData({ merchantSettingInfo })
......
// pages/accountItems/accountItems.js
import api from '../../api/api.js'
const app = getApp()
import { getYQorderInfo } from '~/store/index'
Page({
/**
* 页面的初始数据
......@@ -171,7 +172,8 @@ Page({
} else {
wx.$router.reLaunch('tabIndex.index')
}
app.getYQorderInfo()
// app.
getYQorderInfo()
} else {
wx.$util.showToast(message)
}
......
......@@ -2,16 +2,18 @@ import api from '~/api/api.js'
// console.log(app, 'app')
// console.log(wx)
export const checkYqdSuper = userInfo => {
const app = getApp()
export const checkYqdSuper = (globalData, userInfo) => {
// let that = this
// const app = getApp()
// console.log('app', userInfo)
let merchantAccountType = userInfo.merchantAccountList.every(item => {
return item == 6 || item == 8
})
console.log(getApp(), 'app')
// console.log(globalData, 'app')
// app.globalData.isYqdSuper = userInfo.userType == 2 && !userInfo.isSuper && merchantAccountType
app.globalData.isYqdSuper = userInfo.userType != 2 && !userInfo.isSuper && merchantAccountType
app.globalData.isStaff = userInfo.userType == 2 && !userInfo.isSuper && merchantAccountType
globalData.isYqdSuper = userInfo.userType != 2 && !userInfo.isSuper && merchantAccountType
globalData.isStaff = userInfo.userType == 2 && !userInfo.isSuper && merchantAccountType
globalData.isStaff = 'test'
}
// 获取园区店信息
export const getYQInfo = userInfo => {
......@@ -79,10 +81,11 @@ export const getYQorderInfo = () => {
return new Promise((resolve, reject) => {
// 如果有 直接返回
// console.log(app.globalData.YQorderSetting, 'app.globalData.YQorderSetting')
console.log('app.globalData.YQorderSetting', app.globalData.YQorderSetting)
if (app.globalData.YQorderSetting) {
return resolve(app.globalData.YQorderSetting)
} else {
let userInfo = util.getUserInfo()
let userInfo = wx.$util.getUserInfo()
if (!userInfo) this.login(true)
let { merchantId, merchantName } = userInfo.subLoginUser
......
// tabIndex/pages/index/index.js
import mixins from './index_mixins'
import api from '../../api.js'
import { getYQInfo } from '~/store/index'
const app = getApp()
let time = null
Page({
......@@ -285,7 +286,7 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// console.log(options)
// console.log(app.globalData.isStaff )
if (options.supplement) {
this.setData({
showOrderpop: true
......@@ -335,10 +336,10 @@ Page({
.catch(err => {})
},
init(userInfo) {
app
.getYQInfo(userInfo)
// app.
getYQInfo(userInfo)
.then(result => {
// console.log(result)
console.log(result)
// console.log(app.globalData.isYqdSuper)
this.setData({
...result
......
// tabOperating/pages/operatingShow/operatingShow.js
import api from '../../api.js'
import { getYQInfo } from '~/store/index'
// import WXMLCanvas from '../../wxml-canvas/index'
//设计稿宽度,一般为750
const UI_Width = 750
......@@ -140,8 +141,8 @@ Page({
})
},
init(userInfo) {
app
.getYQInfo(userInfo)
// app .
getYQInfo(userInfo)
.then(result => {
console.log(result)
this.setData({
......
// tabOperating/pages/index.js
import mixins from './index_mixins'
import api from '../../api.js'
import { getYQInfo } from '~/store/index'
const app = getApp()
Page({
/**
......@@ -66,8 +67,8 @@ Page({
this.tapPicker()
},
init(userInfo) {
app
.getYQInfo(userInfo)
// app.
getYQInfo(userInfo)
.then(result => {
console.log(result)
this.setData({
......
// tabOperating/pages/operatingShow/operatingShow.js
import api from '../../api.js'
import { getYQInfo } from '~/store/index'
const app = getApp()
Page({
/**
......@@ -106,8 +107,8 @@ Page({
})
},
init(userInfo) {
app
.getYQInfo(userInfo)
// app.
getYQInfo(userInfo)
.then(result => {
console.log(result)
this.setData({
......
// tabWorkOrder/pages/createOrder/createOrder.js
import deepClone from '~/utils/deepClone'
import api from '../../api'
import { getYQorderInfo } from '~/store/index'
const app = getApp()
let toastList = {
userId: '销售顾问不能为空',
......@@ -690,8 +691,8 @@ Page({
getSetting() {
// 动态获取 车型 车架 车牌 是否必填
let { requiredList } = this.data
app
.getYQorderInfo()
// app.
getYQorderInfo()
.then(merchantSettingInfo => {
// console.log(merchantSettingInfo)
......@@ -709,7 +710,7 @@ Page({
// }
this.setData({
// requiredList: [...new Set(requiredList)],
// phoneShow: merchantSettingInfo.yqPhoneConfig
// phoneShow: merchantSettingInfo.yqPhoneConfig
phoneShow: deepClone(merchantSettingInfo.yqPhoneConfig)
})
// this.setData({ merchantSettingInfo })
......
......@@ -2,6 +2,7 @@
// tabWorkOrder/pages/createOrder/createOrder.js
import deepClone from '~/utils/deepClone'
import api from '../../api'
import { getYQorderInfo } from '~/store/index'
const app = getApp()
let toastList = {
employeeName: '销售顾问不能为空',
......@@ -57,7 +58,7 @@ Page({
// isPlateNumber: false
isStandNo: false,
isShowSubShopMerchant: false,
requiredList: [],
requiredList: []
},
routerBack() {
wx.$router.back()
......@@ -394,8 +395,8 @@ Page({
getSetting() {
// 动态获取 车型 车架 车牌 是否必填
let { isStandNo } = this.data
app
.getYQorderInfo()
// app .
getYQorderInfo()
.then(merchantSettingInfo => {
console.log(merchantSettingInfo)
......@@ -414,8 +415,8 @@ Page({
}
this.setData({
isStandNo,
// phoneShow: merchantSettingInfo.yqPhoneConfig
phoneShow: deepClone(merchantSettingInfo.yqPhoneConfig)
// phoneShow: merchantSettingInfo.yqPhoneConfig
phoneShow: deepClone(merchantSettingInfo.yqPhoneConfig)
})
// this.setData({ merchantSettingInfo })
})
......
// tabWorkOrder/pages/createOrder/createOrder.js
import deepClone from '~/utils/deepClone'
import api from '../../api'
import { getYQorderInfo } from '~/store/index'
const app = getApp()
let toastList = {
userId: '销售顾问不能为空',
......@@ -591,8 +592,8 @@ Page({
getSetting() {
// 动态获取 车型 车架 车牌 是否必填
let { dynamicSetting, requiredList } = this.data
app
.getYQorderInfo()
// app .
getYQorderInfo()
.then(merchantSettingInfo => {
// console.log(merchantSettingInfo)
let dictionaryObj = {
......
// tabWorkOrder/pages/createOrder/createOrder.js
import deepClone from '~/utils/deepClone'
import api from '../../api'
import { getYQorderInfo } from '~/store/index'
let toastList = {
userId: '销售顾问不能为空',
customerName: '车主姓名不能为空',
......@@ -85,42 +86,6 @@ Page({
this.setData({
[`orderObj.${name}`]: value
})
// if (phoneRex.test(value)) {
// // if (orderObj.orderSource) {
// // delete orderObj.orderSource
// // this.setData({
// // orderObj
// // })
// // }
// // api
// // .checkCustomerPhone({
// // phone: value,
// // yqMerchantId: userInfo.merchantId
// // })
// // .then(res => {
// // let { code, data } = res
// // if (code == 0 && data) {
// // let _this = this
// // wx.showModal({
// // content: '系统已存在该客户,请选择下单类型',
// // cancelText: '新增一单',
// // cancelColor: '#323233',
// // confirmText: '旧单补录',
// // confirmColor: '#3582EE',
// // success(res) {
// // let source = 4
// // if (res.confirm) source = 6
// // _this.setData({
// // ['orderObj.orderSource']: source,
// // ['orderObj.orderCode']: null
// // })
// // }
// // })
// // }
// // })
// }
},
changeGender(e) {
......@@ -137,18 +102,7 @@ Page({
car: `${carBrand}|${carType}`
})
},
// chooseCoupon(e) {
// console.log(e)
// let { name } = e.detail
// this.setData({
// couponName: name
// })
// },
back(data) {
// let {orderCode} = data
// page => {
// page.getOrderDetail && page.getOrderDetail()
// }
if (data) {
wx.$router.back(page => {
page.getOrderDetail && page.getOrderDetail(data)
......@@ -195,53 +149,6 @@ Page({
return
}
}
// if (!save) {
// let subOrderList = []
// let priceDisabled = true
// if (orderObj.selectPayType != 0) {
// if (goodsList) {
// goodsList.map(e => {
// let obj = {
// baseGoodsId: e.baseGoodsId,
// upgradeGoodsId: e.id,
// totalPrice: Number(e.price),
// number: e.count
// }
// if (e.price < e.shopMinPrice) priceDisabled = false
// subOrderList.push(obj)
// })
// orderObj.subOrderList = subOrderList
// }
// if (subOrderList.length == 0) {
// this.showToast('商品不能为空')
// return
// }
// } else {
// // 不升级删除商品参数
// delete orderObj.subOrderList
// }
// else {
// if (!orderObj.customerCouponCode) {
// this.showToast('请选择精品礼券')
// return
// }
// }
// if (!priceDisabled) {
// this.showToast('单价不可低于商品最低价')
// return
// }
// }
// console.log(orderObj.subOrderList)
// 统一商品提交字段
// orderObj.subOrderList = orderObj.subOrderList.map(e => {
// return {
// baseGoodsId: e.baseGoodsId,
// upgradeGoodsId: e.id || e.upgradeGoodsId,
// totalPrice: Number(e.price || e.totalPrice),
// number: e.count || e.number
// }
// })
if (!scene) {
if (!orderObj.orderCode) delete orderObj.orderCode
......@@ -250,10 +157,6 @@ Page({
// delete orderObj.customerCouponCode
delete orderObj.customer.createdDate
// console.log(orderObj)
// return
// return console.log(orderObj)
// return
this.showLoading('提交中...')
let paramsList = ['orderCode', 'customerId', 'customerName', 'customerPhone', 'customerSex', 'carBrandId', 'carBrand', 'carChildsBrandId', 'carChildsBrandName', 'carSeriesId', 'carSeriesName', 'standNo', 'plateNumber', 'experienceFlag', 'remark']
......@@ -285,37 +188,6 @@ Page({
// wx.$util.hideLoading()
console.log(err)
})
// api.createWithPay(orderObj).then(res => {
// wx.hideLoading()
// // console.log(orderObj, res)
// let { code, data, message } = res
// if (code == 0) {
// if (save) {
// wx.showModal({
// title: '温馨提示',
// content: '保存成功',
// showCancel: false,
// confirmText: '知道了',
// confirmColor: '#3582EE',
// success(_res_) {
// if (_res_.confirm) {
// wx.$router.back(page => {
// page.search && page.search()
// })
// }
// }
// })
// } else {
// wx.$refresh = true
// wx.$router.redirectTo('confirmOrder', data)
// // 暂时保留跳转页面
// // wx.$router.go('confirmOrder', data)
// }
// } else {
// this.showToast(message)
// }
// })
},
checkRequired(obj) {
// 'merchantId', 'employeeName', 'customerName','sellerUserId', 'sellerName', 'sellerMerchantId', 'customerCouponCode'
......@@ -353,14 +225,6 @@ Page({
}
})
console.log(orderObj)
// 去除优惠券 参数
// delete orderObj.couponName
// if (!orderObj.merchantId) orderObj.merchantId = orderObj.customerInfo.merchantId
// if (!orderObj.merchantId) orderObj.merchantId = orderObj.customerInfo.merchantId
// 使用优惠券的merchantId 避免优惠券和店区不一致的情况
// if (!orderObj.merchantId) orderObj.merchantId = orderObj.merchantCoupon.merchantId
if (!orderObj.customer) orderObj.customer = orderObj.customerInfo
if (!orderObj.customer.customerSex) orderObj.customer.customerSex = 1
......@@ -374,27 +238,11 @@ Page({
getSetting() {
// 动态获取 车型 车架 车牌 是否必填
// let { } = this.data
app
.getYQorderInfo()
// app.
getYQorderInfo()
.then(merchantSettingInfo => {
// console.log(merchantSettingInfo)
// let dictionaryObj = {
// carTypeRequiredFlag: 'carBrand',
// standNoRequiredFlag: 'standNo',
// plateNumRequiredFlag: 'plateNumber'
// }
// // dictionaryObj
// // let requiredList = []
// for (const key in dictionaryObj) {
// if (merchantSettingInfo[key] == 'Y') {
// requiredList.push(dictionaryObj[key])
// }
// }
this.setData({
// requiredList: [...new Set(requiredList)],
// phoneShow: merchantSettingInfo.yqPhoneConfig
phoneShow: deepClone(merchantSettingInfo.yqPhoneConfig)
phoneShow: deepClone(merchantSettingInfo.yqPhoneConfig)
})
// this.setData({ merchantSettingInfo })
})
......@@ -411,21 +259,7 @@ Page({
this.setData(options)
}
},
init(userInfo) {
let { scene, orderObj } = this.data
// if (!orderObj.sellerMerchantName) {
// orderObj.sellerMerchantName = userInfo.merchantName
// orderObj.sellerName = userInfo.name
// orderObj.sellerMerchantId = userInfo.merchantId
// orderObj.sellerUserId = userInfo.uuid
// this.setData({
// orderObj
// })
// }
// this.setData({
// _userInfo: userInfo
// })
},
init(userInfo) {},
remarkConfirm(e) {
let value = e.detail
......@@ -443,51 +277,11 @@ Page({
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
// setTimeout(() => {
// wx.$util.showLoading()
// }, 2000)
},
onShow: function () {},
onRoute(res) {
// console.log(res)
// if (res.scene) {
// res.returnFun = true
// this.setData(res)
// } else if (res.merchantId) {
// this.setData({
// returnFun: true
// })
// console.log(111)
// 重新赋值清空
// const orderObj = {
// customer: {
// customerName: '',
// customerPhone: '',
// standNo: '',
// plateNumber: '',
// customerSex: 1,
// experienceFlag: 'Y'
// },
// selectPayType: 2,
// remark: ''
// }
// this.setData({
// orderObj
// })
// 避免数据污染到上一页
let obj = JSON.parse(JSON.stringify(res))
this.setOrderObj(obj)
// } else {
// wx.$util.showLoading('加载中...')
// this.setData(
// {
// flag: true
// },
// () => {
// wx.$util.hideLoading()
// }
// )
// }
this.getSetting()
},
/**
......
import { preReleaseAppId } from '~/config'
const target = ['ip', 'dev', 'uat', 'prod', 'preRelease']
/**
*
0本地
1开发
2测试
3生产
*/
// const index = 1
const accountInfo = wx.getAccountInfoSync()
const systemInfo = wx.getSystemInfoSync()
// console.log(systemInfo);
// console.log(accountInfo.miniProgram.envVersion)
//手动控制体验版环境的请求 true就依据下面index false就默认为2
const manual = false
const release = false
let index = 2
// 判断小程序环境
// develop:开发版(正常开发工具,测试时)
// trial:体验版
// release:正式版
// console.log( systemInfo.platform);
// console.log(accountInfo.miniProgram.envVersion);
// 对比一下appkey
// console.log();
if (systemInfo.platform != 'devtools') {
// 判断预发布的appid 是强制锁定为4(预发布的地址)
if (accountInfo.miniProgram.appId == preReleaseAppId) {
index = 4
} else {
switch (accountInfo.miniProgram.envVersion) {
case 'develop':
// this.globalData.url = 'http://192.168.0.252:3000/api'; //
break
case 'trial':
index = manual ? index : 2
break
case 'release':
index = release ? index : 3
break
default:
index = 3
break
}
}
}
const secretKey = {
ip: {},
dev: {
sso: {
appKey: '8b31ae1009ccb0f96130ca4bd90e3d89',
secret: '02d60f17ae714872845d2aa9d3b087e109ccb0f96130ca4b'
}
},
uat: {
sso: {
appKey: '8b31ae1009ccb0f96130ca4bd90e3d89',
secret: '02d60f17ae714872845d2aa9d3b087e109ccb0f96130ca4b'
}
},
prod: {
sso: {
appKey: '8b31ae1009ccb0f96130ca4bd90e3d89',
secret: '02d60f17ae714872845d2aa9d3b087e109ccb0f96130ca4b'
}
},
preRelease: {
sso: {
appKey: '8b31ae1009ccb0f96130ca4bd90e3d89',
secret: '02d60f17ae714872845d2aa9d3b087e109ccb0f96130ca4b'
}
}
}[target[index]]
const domain = {
// ip: 'http://192.168.2.94:8558',
// ip: 'http://192.168.2.3:8315',
ip: 'http://192.168.1.170:8315',
/**登录: 192.168.2.3:8315
商城: 192.168.2.3:8558 */
dev: 'https://scrm.dev.glsx.com.cn',
uat: 'https://scrm.test.glsx.com.cn',
preRelease: 'https://scrm.beta.glsx.com.cn',
prod: 'https://scrm.glsx.com.cn'
}[target[index]]
const pathEnum = {
sso: '/rop-scrm-sso/',
shopmall: '/rop-scrm-shopmall/',
coupon: '/rop-scrm-coupon/',
carlife: '/rop-scrm-carlife/',
live: '/rop-scrm-live/',
equity: '/rop-scrm-equity/',
entmicro: '/rop-scrm-entmicro/',
wechat: '/rop-scrm-wechat/',
boutiquecoupon: '/rop-scrm-boutiquecoupon/',
material: '/rop-scrm-marketing/', //素材
sop: '/rop-scrm-sop/',
customercollect: '/rop-scrm-bigdatautil/',
drac: '/rop-scrm-entmicro/',
busassistant: '/rop-scrm-busassistant/'
}
const defaultMerchantId = {
ip: '44184606',
dev: '44184606',
uat: '44184606',
preRelease: '44184606',
prod: '44189923'
}[target[index]]
module.exports = {
index,
domain,
pathEnum,
secretKey,
defaultMerchantId
}
/**
*
0本地
1开发
2测试
3生产环境
*/
const accountInfo = wx.getAccountInfoSync()
const systemInfo = wx.getSystemInfoSync()
// console.log(systemInfo);
// console.log(accountInfo.miniProgram.envVersion)
//手动控制体验版环境的请求 true就依据下面index false就默认为2
const manual = false
const release = false
let index = 2
// 判断小程序环境
// develop:开发版(正常开发工具,测试时)
// trial:体验版
// release:正式版
// console.log( systemInfo.platform);
// console.log(accountInfo.miniProgram.envVersion);
if (systemInfo.platform != 'devtools') {
switch (accountInfo.miniProgram.envVersion) {
case 'develop':
// this.globalData.url = 'http://192.168.0.252:3000/api'; //
break
case 'trial':
index = manual ? index : 2
break
case 'release':
index = release ? index : 3
break
default:
index = 3
break
}
}
// console.log(index);
const secretKey_items = {
ip: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637',
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
},
dev: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637',
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
},
uat: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637',
secret: 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
},
prod: {
appKey: 'd7ffc3346fc9a45bccaaa35300d59022',
secret: '4bc07f8868374c49a4661d603377e3106fc9a45bccaaa353'
},
preRelease: {
appKey: 'd7ffc3346fc9a45bccaaa35300d59022',
secret: '4bc07f8868374c49a4661d603377e3106fc9a45bccaaa353'
}
}
const domain_items = {
// ip: 'http://192.168.2.59:8292',
// ip: 'http://192.168.1.129:8392',
// ip: 'http://192.168.1.129:8292',
ip: 'http://192.168.1.165:8292',
// ip: 'http://192.168.2.3:8292',
dev: 'https://dj.dev.glsx.com.cn',
uat: 'https://dj.test.glsx.com.cn',
// uat: 'https://dj.beta.glsx.com.cn',
prod: 'https://dj.glsx.com.cn',
preRelease: 'https://dj.beta.glsx.com.cn'
}
const target = ['ip', 'dev', 'uat', 'prod', 'preRelease']
// console.log(domain_items[target[index]]);
module.exports = {
domain: domain_items[target[index]],
secretKey: secretKey_items[target[index]]
}
import sha1 from '../lib/sha1.js'
import qs from '../lib/qs'
import environment from './environment.js'
const sign = (params, secret, noSignAttr = []) => {
delete params.sign
var objStr = qs.stringify(params, {
arrayFormat: 'indices',
allowDots: true,
encodeValuesOnly: true
})
var objVal = objStr.split('&')
var realObj = {}
objVal.forEach(item => {
const idx = item.indexOf('=')
realObj[item.split('=')[0]] = decodeURIComponent(item.slice(idx + 1))
})
const keys = Object.keys(realObj).sort()
var str = []
var obj = null
for (const key in realObj) {
obj = realObj[key]
if (obj === null) {
obj = ''
} else if (typeof obj === 'object') {
obj = JSON.stringify(obj)
}
realObj[key] = obj
}
keys.forEach(e => {
!noSignAttr.includes(e) && str.push(e + realObj[e])
})
realObj.sign = sha1(secret + str.join('') + secret).toUpperCase()
return realObj
}
module.exports = {
...environment,
sign
}
import environment from './environment.js'
import sha1 from '~/utils/lib/sha1'
import qs from '~/utils/lib/qs'
const path = '/rop-dj-car-boutique/router'
const sign = (params, secret, noSignAttr = []) => {
delete params.sign
var objStr = qs.stringify(params, {
arrayFormat: 'indices',
allowDots: true,
encodeValuesOnly: true
})
var objVal = objStr.split('&')
var realObj = {}
objVal.forEach(item => {
const idx = item.indexOf('=')
realObj[item.split('=')[0]] = decodeURIComponent(item.slice(idx + 1))
})
const keys = Object.keys(realObj).sort()
var str = []
var obj = null
for (const key in realObj) {
obj = realObj[key]
if (obj === null) {
obj = ''
} else if (typeof obj === 'object') {
obj = JSON.stringify(obj)
}
realObj[key] = obj
}
keys.forEach(e => {
!noSignAttr.includes(e) && str.push(e + realObj[e])
})
realObj.sign = sha1(secret + str.join('') + secret).toUpperCase()
return realObj
}
module.exports = {
...environment,
path,
sign
}
import { secretKey, pathEnum, domain, sign } from './http.js'
import { getSessionId } from '~/utils/cache/storageApi'
import network from '~/utils/network'
/**接口 */
class Request {
get(params, returnAll = false) {
return this.request('GET', params, returnAll)
}
post(params, returnAll = false) {
return this.request('POST', params, returnAll)
}
async request(RequestMethods, params, returnAll) {
const type = await network.getNetworkType()
if (type == 'none') return
return new Promise((resolve, reject) => {
wx.showNavigationBarLoading()
let header =
RequestMethods === 'POST'
? {
'content-type': 'application/x-www-form-urlencoded'
}
: {}
let projectName = params.apiProjectName || this.getRopProject(params.method)
if (!projectName) projectName = this.getRopProject(params.method)
let path = pathEnum[projectName]
if (!path) path = `/rop-scrm-${projectName}/`
params = this.getData(params)
wx.request({
url: `${domain}${path}router?method=${params.method}`,
data: params,
method: RequestMethods,
header,
dataType: 'json',
responseType: 'text',
success(response) {
/**业务代码 */
let {
data: { code, message },
data
} = response
if (code == 20 || code == 21) {
wx.$storage.rm('sessionId')
wx.$storage.rm('userInfo')
const thisPage = wx.$router.getPageInstance(),
autoLoginObject = wx.$storage.get('auto_login_object')
if (thisPage.route == 'login/loading/loading') {
resolve(data)
return
} else {
if (autoLoginObject) wx.$router.reLaunch('login.loading')
else wx.$router.reLaunch('login.index')
}
} else {
if (returnAll) {
resolve(data)
return
}
if (code == '0') {
resolve(data.data)
} else {
// console.trace(data)
wx.showToast({
title: message || '网络请求失败',
icon: 'none'
})
}
}
},
fail(error) {
wx.hideLoading()
console.log(`接口异常:`, error)
wx.showToast({
title: '网络请求失败',
icon: 'error'
})
reject(error)
},
complete() {
wx.stopPullDownRefresh()
wx.hideNavigationBarLoading()
}
})
})
}
getData(params) {
let projectName = params.projectName
if (!projectName) projectName = this.getRopProject(params.method)
else delete params.projectName
let appKey = '48e5e13229b82c1b4e6e8c96151f0637'
let secret = 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
if (secretKey[projectName]) {
appKey = secretKey[projectName].appKey
secret = secretKey[projectName].secret
}
const sessionId = getSessionId()
let noSignAttr = []
if (!params.sessionId && sessionId) params.sessionId = sessionId
if (params.noSignAttr) {
noSignAttr = params.noSignAttr
delete params.noSignAttr
}
params.v = '1.0.0'
params.format = 'json'
params.locale = 'zh_CN'
params.source = 'dj-wechat'
params.appKey = appKey
return sign(params, secret, noSignAttr)
}
getRopProject(method) {
const projectName = method.split('.')[2]
return projectName
}
}
export default new Request()
import { secretKey, domain, path, sign } from './http.js'
import util from '~/utils/util.js'
/**接口 */
class Request {
get(method, data, noSignAttr) {
return this.request('GET', method, data, noSignAttr)
}
post(method, data, noSignAttr) {
return this.request('POST', method, data, noSignAttr)
}
request(RequestMethods, method, data, noSignAttr = []) {
let _this = this
return new Promise((resolve, reject) => {
wx.showNavigationBarLoading()
if (!data) data = {}
let header =
RequestMethods === 'POST'
? {
'content-type': 'application/x-www-form-urlencoded'
}
: {}
data = _this.getData(data, method, noSignAttr)
wx.request({
url: `${domain}${path}?method=${method}`,
data,
method: RequestMethods,
header,
dataType: 'json',
responseType: 'text',
success(response) {
/**业务代码 */
let {
data: { code, message },
data
} = response
// let thisPage = wx.$router.getPageInstance()
// // console.log(thisPage, 'thisPage')
// let { route, data: pageData } = thisPage
// if (pageData.shareQuery) {
// wx.$util.setStorageSync('shareQuery', {
// route,
// shareQuery: pageData.shareQuery
// })
// }
if (code == 20 || code == 21) {
wx.hideLoading()
wx.showModal({
title: '温馨提示',
content: '登录过期,请重新登录。',
showCancel: false,
confirmText: '去登录',
confirmColor: '#3582EE',
success(res) {
if (res.confirm) {
getApp().login(true)
}
}
})
} else if (code == -1) {
wx.showToast({
title: message || '网络请求失败',
icon: 'none'
})
resolve(data)
} else {
resolve(data)
}
},
fail(error) {
wx.hideLoading()
console.error(`接口异常:${domain}${path}?method=${method}`, error)
wx.showToast({
title: '系统异常',
icon: 'error'
})
reject(error)
// if (fail && typeof fail == 'function') {
// fail(error, reject)
// } else {
// }
},
complete() {
wx.stopPullDownRefresh()
wx.hideNavigationBarLoading()
}
})
})
}
getData(data, method, noSignAttr) {
let sessionId = util.getSessionId()
if (sessionId) data['sessionId'] = sessionId
data['v'] = '1.0.0'
data['method'] = method
data['format'] = 'json'
data['locale'] = 'zh_CN'
data['source'] = 'dj-wechat'
data['appKey'] = secretKey.appKey
let obj = sign(data, secretKey.secret, noSignAttr)
//data['sign'] = obj.sign;
return obj
}
}
export default new Request()
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!