Commit fe302537 by chenwq

自动登录

1 parent 848c7cf2
......@@ -20,5 +20,22 @@ module.exports = {
noSignAttr: ['file']
})
},
/** mock */
getMock() {
let url = 'https://oss-config.dev.glsx.com.cn/mock/63fd6c2034c4d918e2f4df4d/config'
return new Promise((resolve) => {
wx.request({
url,
data: {},
method: 'GET',
header: {},
dataType: 'json',
responseType: 'text',
success(response) {
resolve(response.data)
}
})
})
}
}
}
......@@ -126,7 +126,7 @@
height: 40rpx;
line-height: 40rpx;
margin-top: 22rpx;
font-size: 24rpx;
font-size: 20rpx;
color: #3666FE;
/* font-weight: 600; */
font-family: 'number';
......
......@@ -2,6 +2,8 @@ import { checkLoginUserInfo, setRouteData, setLoginInfo, loginModal } from '../l
import { getSessionId } from '~/utils/cache/storageApi'
import USERAPI from '~/api/usersApi/index'
import { IMG_URL } from '~/utils/constantData'
import md5 from '~/utils/lib/md5'
import { sceneByIdApi } from '~/api/checkProduct.js'
Page({
/**
* 页面的初始数据
......@@ -13,12 +15,12 @@ Page({
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {},
onLoad(options) { },
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {},
onReady() { },
/**
* 生命周期函数--监听页面显示
......@@ -31,28 +33,52 @@ Page({
if (extraData && Object.keys(extraData).length) this.phoneSmsLogin(extraData)
else this.init()
} else this.init()
} else if ([1011, 1012, 1013].includes(appEnter.scene)) {
sceneByIdApi({
id: decodeURIComponent(appEnter.query.scene).split('=')[1]
}).then(res => {
const url = res.scene
const obj = this.arrToObj(url.split('&'))
if (obj.hasOwnProperty('userName') && obj.hasOwnProperty('password')) {
this.accountLogin(obj)
} else this.init()
}).catch(() => {
this.init()
})
} else this.init()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {},
onHide() { },
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {},
onUnload() { },
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {},
onPullDownRefresh() { },
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
onReachBottom() { },
arrToObj(list) {
if (!Array.isArray(list)) {
return {}
}
var obj = {}
list.forEach(item => {
let temp = item.split('=')
obj[temp[0]] = temp[1]
})
return obj
},
init() {
wx.nextTick(() => {
const sessionId = getSessionId(),
......@@ -102,7 +128,6 @@ Page({
} else wx.$router.reLaunch('login.index', obj)
},
phoneSmsLogin(extraData) {
console.log(extraData)
USERAPI.phoneSmsLogin({
mobile: extraData.phone,
code: extraData.smscode
......@@ -122,5 +147,41 @@ Page({
wx.$router.reLaunch('login.index')
}, 1e3)
})
},
accountLogin(obj) {
const params = {
userName: obj.userName,
password: md5(obj.password)
}
USERAPI.accountLogin(params).then(({ code, data, message }) => {
if (code == '0') {
const { sessionId, loginUserInfoList } = data
var routeParams = {}
setLoginInfo(loginUserInfoList[0], sessionId)
if (obj.url == '/packagesList/packageOutput/pages/summary') {
routeParams = {
merchantId: obj.merchantId,
merchantName: obj.merchantName,
pMerchantId: loginUserInfoList[0].subLoginUser.merchantId,
pMerchantName: loginUserInfoList[0].subLoginUser.merchantName,
isSuper: loginUserInfoList[0].isSuper,
fixScenceCode: obj.sceneCode
}
// console.log(routeParams, 'routeParams---')
}
wx.$router.reLaunch(obj.url, routeParams)
} else {
wx.$api.showToast(message || '系统异常')
setTimeout(() => {
wx.$router.reLaunch('login.index')
}, 1e3)
}
})
.catch(err => {
wx.$api.showToast('系统异常')
setTimeout(() => {
wx.$router.reLaunch('login.index')
}, 1e3)
})
}
})
......@@ -13,10 +13,14 @@ Component({
properties: {
orderObj: {
type: Object,
value: () => {},
value: () => { },
observer(n) {
n && this.dealStaffList()
}
},
hasReport: {
type: Boolean,
value: true
}
},
......@@ -164,7 +168,7 @@ Component({
path: obj.path
})
},
fail() {}
fail() { }
})
})
},
......@@ -174,6 +178,15 @@ Component({
},
async download(e) {
const { item } = e.currentTarget.dataset
if (item.mockPoster) {
item.posterUrl = item.mockPoster
this.setData({
crowdPosterItem: item,
isShowTip: false
})
return
}
// posterObj = this.selectComponent('#crowdPoster'),
// { options } = wx.$router.getPageInstance()
// const { options } = wx.$router.getPageInstance()
......@@ -213,7 +226,7 @@ Component({
this.triggerEvent('posterTrack')
},
/**长按战报/喜报 */
async handlePosterTouch(e) {},
async handlePosterTouch(e) { },
/**战报 */
handleReport(e) {
const { item, idx } = e.currentTarget.dataset
......
......@@ -79,7 +79,7 @@
</view>
</view>
<!-- 战报 -->
<view class="new-report" wx:if="{{item.activityStatus != 1}}">
<view class="new-report" wx:if="{{item.activityStatus != 1 && hasReport}}">
<view class="report-left" bindtap="handleReport" data-item="{{item}}" data-idx="{{index}}">生成最新战报</view>
<view class="report-left" bindtap="handleXiReport" data-item="{{item}}" data-idx="{{index}}">生成最新喜报</view>
</view>
......
......@@ -24,7 +24,8 @@ const formList = [{
label: '体验转化率',
name: 'calTransform',
suffix: '%'
}]
}
]
const formObj = {
SC001: [{
......@@ -43,8 +44,7 @@ const formObj = {
prefix: '¥'
}, {
label: '转化率',
name: 'conversionRate',
suffix: '%'
name: 'conversionRate'
}, {
label: '单价',
name: 'price',
......
// packageOutput/pages/summary/summary.js
import outputApi from '~/api/outputApi/index'
import { commonApi } from '~/api/api'
import { IMG_URL } from '~/utils/constantData'
import { getNowMonth } from '~/utils/format'
import utils from '~/utils/util.js'
const defaultSceneCode = 'SC004'
Page({
/**
......@@ -11,7 +13,17 @@ Page({
IMGURL: IMG_URL,
sceneCodeList: ['SC002', 'SC003', 'SC004', 'SC001'],
merchantInfo: {},
sceneInfo: {},
sceneInfo: {
sceneList: [{
sceneCode: "SC002", flag: false
}, {
sceneCode: "SC003", flag: false
}, {
sceneCode: "SC004", flag: false
}, {
sceneCode: "SC001", flag: false
}]
},
sceneData: {},
// sceneObj: {
// scene1: null,
......@@ -45,6 +57,7 @@ Page({
scene2: [],
scene3: []
},
fixScenceCode: '-1',
// 产值
searchForm: {
sceneSC002: 0,
......@@ -54,6 +67,13 @@ Page({
baseData: {
timeList: ['全部', '本月', '本日'],
actStatusList: ['全部', '申请中', '活动中', '已结束']
},
mockObj: {},
isMock: {
'SC001': false,
'SC002': false,
'SC003': false,
'SC004': false
}
},
......@@ -143,6 +163,12 @@ Page({
// 定位已开通的场景,默认定位至场景4
findOpenScene() {
let sceneCodeActive = defaultSceneCode
if (this.data.fixScenceCode != '-1') {
this.setData({
sceneCodeActive: this.data.fixScenceCode || 'SC004'
})
return
}
const list = []
this.data.sceneCodeList.forEach(item => {
let sceneIsOpen = this.data.sceneData.find(k => k.sceneCode == item)?.sceneIsOpen
......@@ -199,6 +225,9 @@ Page({
if (!['SC001'].includes(this.data.sceneCodeActive)) {
this.getEquityRevenue(isFirst)
}
if (!['SC004'].includes(this.data.sceneCodeActive)) {
this.getActivityRevenue(isFirst)
}
}
// console.log(this.data.sceneCodeActive == defaultSceneCode)
if (['SC002', 'SC003'].includes(this.data.sceneCodeActive)) {
......@@ -266,11 +295,10 @@ Page({
var idx = actCodeList.findIndex(i => i == item.productCode)
var orderTotal = item.orderTotal
if (item.orderTotal) {
item.orderTotal.totalAmount = Number(orderTotal.totalAmount).toFixed(2)
total = (total + Number(item.orderTotal?.totalAmount)).toFixed(2)
item.orderTotal.totalAmount = utils.moneyThreeForTwoThousands(Number(orderTotal.totalAmount).toFixed(2))
item.orderTotal.monthAmount = Number(orderTotal.monthAmount).toFixed(2)
item.orderTotal.conversionRate = Number(orderTotal.conversionRate).toFixed(0)
item.orderTotal.price = Number(orderTotal.price).toFixed(2)
total = (total + Number(item.orderTotal?.totalAmount)).toFixed(2)
}
actList[idx] = {
...actList[idx],
......@@ -301,11 +329,15 @@ Page({
var curTotal = 0
var otherTotal = 0
var otherSceneIdx = isFirst ? this.findSceneIdx('SC002') : this.data.sceneCodeActive == 'SC002' ? this.findSceneIdx('SC003') : this.findSceneIdx('SC002')
let obj = this.judgeUpgrade()
res.forEach(item => {
var idx = actCodeList.findIndex(i => i == item.productCode)
if (idx != -1) {
var orderTotal = item.orderTotal
if (item.orderTotal) {
if (this.data.sceneCodeActive == 'SC002' && obj.flag) {
let upgradeObj = this.data.mockObj.upgradeObj[obj.idx]
item.orderTotal = upgradeObj.orderTotal
} else if (item.orderTotal) {
item.orderTotal.calCustomerUnitPrice = Math.round(orderTotal.totalSubOrderOrderMoney / orderTotal.upgradeCount).toFixed(2)
item.orderTotal.calExperience = Math.round((orderTotal.experienceCount * 100) / orderTotal.toShopCount).toFixed(0)
item.orderTotal.calTransform = Math.round((orderTotal.upgradeCount * 100) / orderTotal.experienceCount).toFixed(0)
......@@ -360,8 +392,28 @@ Page({
return params
},
/**处理SC004的数据 */
mockDealCrowd(data) {
var obj = this.judgeCrowd(this.data.merchantInfo.pMerchantId, data.merchantId)
if (!obj.flag) {
return data
}
var mockActivityList = this.data.mockObj?.crowdObj[obj.pIdx].merchantList[obj.idx].activityList
var actIds = mockActivityList.map(item => item.activityId)
// console.log(mockActivityList, 'mockActivityList')
data.activityList.forEach(item => {
let idx = actIds.findIndex(k => k == item.activityId)
if (idx != -1) {
item.activityName = mockActivityList[idx].activityName
item.mockPoster = mockActivityList[idx].postUrl
}
})
return data
},
/** 查询场景4的产值 */
getActivityRevenue(isFirst = false) {
console.log(this.data.isMock, 'SC004--mock---')
wx.showLoading()
var params = this.dealSearchStatus()
outputApi
......@@ -377,6 +429,7 @@ Page({
actList.forEach((item, idx) => {
var curItem = res.find(k => k.goodsCategoryCode == item.productCode)
if (curItem) {
curItem = this.mockDealCrowd(curItem)
curItem.totalNum = curItem.activityList.length
curItem.shareBtnIdx = -1
let shareFlag = false
......@@ -473,6 +526,15 @@ Page({
// show: true
// })
// } catch (error) {
if (item.mockPoster) {
item.posterUrl = item.mockPoster
this.setData({
crowdPosterItem: item,
isShowTip: false
})
return
}
wx.$api.showLoading('加载中...')
outputApi
.getPosterUrl({
......@@ -516,26 +578,109 @@ Page({
this.setCurActivity()
},
// 精品升级-SC002
judgeUpgrade(pId, id) {
let res = {
flag: false,
idx: -1
}
let pMerchantId = pId || this.data.merchantInfo.pMerchantId
let merchantId = id || this.data.merchantInfo.merchantId
if (this.data.mockObj?.upgradeObj) {
let pList = this.data.mockObj.upgradeObj.map(item => item.pMerchantId)
for (let i = 0; i < this.data.mockObj.upgradeObj.length; i++) {
let item = this.data.mockObj.upgradeObj[i]
if (item.pMerchantId == pMerchantId && item.merchantId == merchantId) {
res = {
flag: true,
idx: i
}
break
}
}
}
return res
},
// 售后众筹-SC004
judgeCrowd(pId, id) {
let res = {
flag: false,
pIdx: -1,
idx: -1
}
if (this.data.mockObj?.crowdObj) {
let pList = this.data.mockObj.crowdObj.map(item => item.pMerchantId)
for (let i = 0; i < this.data.mockObj.crowdObj.length; i++) {
let item = this.data.mockObj.crowdObj[i]
console.log(item, 'item---')
let cList = item.merchantList.map(k => k.merhantId)
if (cList.includes((id || this.data.merchantInfo.merchantId) + '') && pList.includes((pId || this.data.merchantInfo.pMerchantId) + '')) {
res = {
flag: true,
pIdx: i,
idx: cList.findIndex(k => k == (id || this.data.merchantInfo.merchantId))
}
break
}
}
}
return res
},
// 判断是否Mock数据写死
judgeAccount() {
console.log(this.data.merchantInfo, 'this.data.merchantInfo')
console.log(this.data.mockObj, 'this.data.mockObj')
// 精品升级-SC002
// 售后众筹-SC004
this.setData({
['isMock.SC002']: this.judgeUpgrade().flag,
['isMock.SC004']: this.judgeCrowd().flag
})
console.log(this.data.isMock, 'isMock---')
},
// 二维码自动登录
onRoute(options) {
if (!options.hasOwnProperty('fixScenceCode')) {
return
}
this.setData({
merchantInfo: options,
fixScenceCode: options.fixScenceCode
})
commonApi.getMock().then(res => {
// console.log(res, '---')
this.setData({
mockObj: res
})
this.judgeAccount()
this.getSceneProStatus(this.data.sceneCodeList[this.findSceneIdx()], true)
})
},
/**
* 生命周期函数--监听页面加载
* 从client跳转
*/
onLoad(options) {
this.initTime()
wx.$router.getData(obj => {
var list = []
this.data.sceneCodeList.forEach(item => {
let temp = obj.sceneList.find(k => k.sceneCode == item) || {}
list.push(temp)
})
console.log(obj, 'summary---onload')
this.setData({
merchantInfo: obj,
sceneInfo: {
sceneList: list
}
// sceneCodeList: obj.sceneCodeList
})
this.getSceneProStatus(this.data.sceneCodeList[this.findSceneIdx()], true)
commonApi.getMock().then(res => {
console.log(res, '---')
this.setData({
mockObj: res
})
this.judgeAccount()
this.getSceneProStatus(this.data.sceneCodeList[this.findSceneIdx()], true)
})
})
},
......@@ -549,7 +694,7 @@ Page({
*/
onReady() {
wx.setNavigationBarTitle({
title: this.data.merchantInfo.merchantName
title: this.data.merchantInfo?.merchantName
})
},
......
......@@ -31,17 +31,18 @@
<view class="activity-title title bg-white p-l-20 no-border">
<view>看产值</view>
<view wx:if="{{sceneCodeActive != 'SC001'}}" class="select" bindtap="handleSearch">
<view wx:if="{{sceneCodeActive == 'SC002' || sceneCodeActive == 'SC003'}}" class="select-txt">
<view wx:if="{{(sceneCodeActive == 'SC002' || sceneCodeActive == 'SC003') && !isMock.SC002}}" class="select-txt">
{{baseData.timeList[sceneCodeActive == 'SC002' ? searchForm.sceneSC002 : searchForm.sceneSC003]}}
<image class="icon-arrow" src="{{IMGURL}}output/arrow.png?v={{img_version}}" />
</view>
<view wx:if="{{sceneCodeActive == 'SC004'}}" class="select-txt">
<view wx:if="{{sceneCodeActive == 'SC004' && !isMock.SC004}}" class="select-txt">
{{baseData.actStatusList[searchForm.sceneSC004]}}
<image class="icon-arrow" src="{{IMGURL}}output/arrow.png?v={{img_version}}" />
</view>
<image class="icon-arrow" src="{{IMGURL}}output/arrow.png?v={{img_version}}" />
</view>
</view>
<output-transform wx:if="{{sceneCodeActive != 'SC004'}}" formData="{{activityList[activityActive].orderTotal}}" hasNavigate="{{sceneCodeActive != 'SC001'}}" sceneCode="{{sceneCodeActive}}"/>
<output-crowdfund wx:if="{{sceneCodeActive == 'SC004'}}" orderObj="{{activityList[activityActive].outputData}}" bind:handleZhanReport="handleZhanReport" bind:posterTrack="posterTrack"/>
<output-transform wx:if="{{sceneCodeActive != 'SC004'}}" formData="{{activityList[activityActive].orderTotal}}" hasNavigate="{{sceneCodeActive != 'SC001' && !isMock.SC002}}" sceneCode="{{sceneCodeActive}}" />
<output-crowdfund wx:if="{{sceneCodeActive == 'SC004'}}" orderObj="{{activityList[activityActive].outputData}}" bind:handleZhanReport="handleZhanReport" bind:posterTrack="posterTrack" hasReport="{{isMock.SC004}}" />
</view>
<view wx:else class="content-empty bg-white">
<image class="img-empty" src="{{IMGURL}}output/sum-empty.png?v={{img_version}}" />
......
......@@ -113,7 +113,7 @@
height: 40rpx;
line-height: 40rpx;
margin-top: 36rpx;
font-size: 24rpx;
font-size: 22rpx;
color: #3666FE;
/* font-weight: 600; */
font-family: "number";
......
......@@ -153,7 +153,7 @@ Component({
// scene2: currentItem.scene2,
// scene3: currentItem.scene3,
// scene4: currentItem.scene4,
sceneList: currentItem.sceneList,
// sceneList: currentItem.sceneList,
// sceneCodeList: currentItem.sceneList.map(item => item.sceneCode),
pMerchantId: this.data.pMerchantId,
pMerchantName: this.data.pMerchantInfo.subLoginUser.merchantName,
......
......@@ -80,6 +80,13 @@
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "login/loading/loading",
"query": "scene=sceneId%3D22401",
"launchMode": "default",
"scene": 1011
}
]
}
......
......@@ -256,6 +256,38 @@ const setNavigationBarTitle = (title) =>{
});
}
/** 钱转化千分 */
const moneyThreeForTwoThousands = num => {
//num = parseInt(num);
// return num
var num = num + ''
var d = ''
if (num.slice(0, 1) == '-') {
d = num.slice(0, 1)
num = num.slice(1)
}
var len = num.length
var index = num.indexOf('.')
if (index == -1) {
num = num + '.00'
} else if (index + 2 == len) {
num = num + '0'
}
var index = num.indexOf('.') // 字符出现的位置
var num2 = num.slice(-3)
num = num.slice(0, index)
var result = ''
while (num.length > 3) {
result = ',' + num.slice(-3) + result
num = num.slice(0, num.length - 3)
}
if (num) {
result = num + result
}
// return result
return d + (result + num2)
}
const Util = {
getImgVersion,
......@@ -267,6 +299,7 @@ const Util = {
parseString,
getCurrentPageUrl,
deepClone,
setNavigationBarTitle
setNavigationBarTitle,
moneyThreeForTwoThousands
};
export default Util;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!