Commit 10232ed4 by 胡悦

提交

1 parent 41fad4c1
......@@ -26,7 +26,8 @@ App({
if (options.path != 'pages/tab/index/index') {
this.login()
}
// wx.showMeasure = false
wx.showMeasure = !!options.query.scene
},
login(returnResponse) {
let _this = this
......@@ -48,6 +49,7 @@ App({
openId = wechatInfo.openId
// util.setStorageSync('openId', openId)
console.log(wx.$trackData)
wx.showMeasure = !!wx.$trackData.scene
if (wx.$trackData.scene && !wx.firstVisiter) {
// 初次进入小程序默认埋首页
_this.getScene(wx.$trackData.scene).then(res => {
......
// pages/measure/measure.js
import Util from '../../../utils/util'
import measureData from '../constant/data'
const checkMap = new Map()
Page({
......@@ -9,7 +10,7 @@ Page({
*/
data: {
measureList: null,
measureList: measureData.measureList,
isDisabled: true,
checkArray: [],
formData: {
......@@ -112,11 +113,6 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
console.log(measureData)
this.setData({
measureList: measureData.measureList
})
console.log(this.data.measureList)
},
/**
......
// pages/measureResult/measureResult.js
import Util from '../../../utils/util'
import measureData from '../constant/data'
Page({
......@@ -119,6 +120,7 @@ Page({
} else {
const {countList} = this.data
const countData = {}
console.log(checkList)
checkList.forEach(i => {
countList.forEach(j => {
const value = this.formula(j, {}, checkList)
......@@ -135,7 +137,7 @@ Page({
console.log(item)
this.setData({
visible: true,
'dialogData.rate': item.rate * 1000 / 10,
'dialogData.rate': (item.rate * 10000 / 100).toFixed(2),
'dialogData.averagePrice': item.averagePrice,
'dialogData.index': index
});
......@@ -197,7 +199,9 @@ Page({
const reg = /^[1-9]\d*$/
const reg1 = /^[1-9]{0,1}\d{1}(.\d{0,2})$/
console.log(value <100 && value > 0, (reg.test(value) || reg1.test(value)))
if (value < 0) {
// if ()
// value = value.replace(/\D/g, '')
if (value <= 0) {
value = null
} else if (value > 100) {
value = value.slice(0,2)
......@@ -208,6 +212,9 @@ Page({
const integer = value.split('.')[0]
value = integer + '.' + decimal
}
} else {
console.log(value)
value = value.slice(0, value.length - 1)
}
this.setData({
'dialogData.rate': value
......@@ -220,16 +227,16 @@ Page({
onLoad(options) {
wx.$router.getData(res => {
console.log(res)
const list = Util.deepClone(res)
this.setData({
formData: res
formData: list
})
const checkList = this.getCalculate(res.checkArray)
const countData = this.getCalculate(res.checkArray, true)
const checkList = this.getCalculate(list.checkArray)
const countData = this.getCalculate(list.checkArray, true)
console.log(checkList)
this.setData({
checkList,
countData,
})
console.log(countData)
})
......
......@@ -51,7 +51,7 @@
</view>
<view class="card-item">
<view class="card-label gray m-b-4">转化率</view>
<view class="card-value color value-number">{{(m.rate * 1000 / 10)}}%</view>
<view class="card-value color value-number">{{filter.decimalFormat(m.rate)}}%</view>
</view>
<view class="card-item">
<view class="card-label gray m-b-4">客单均价</view>
......@@ -99,7 +99,7 @@
</view>
<view class="card-item">
<view class="card-label gray m-b-8">转化率</view>
<view class="card-value color value-number">{{(n.rate * 1000 / 10)}}%</view>
<view class="card-value color value-number">{{(n.rate * 10000 / 100)}}%</view>
</view>
<view class="card-item">
<view class="card-label gray m-b-8">客单均价</view>
......@@ -180,5 +180,9 @@ function formatValue(value) {
console.log(value, typeof value, value.toString().length, value.toString().length >= 8 ? (value / 10000).toFixed(0) + '万' : value)
return value.toString().length >= 8 ? (value / 10000).toFixed(0) + '万' : value
}
function decimalFormat(value) {
return (value * 100).toFixed(2)
}
module.exports.formatValue = formatValue
module.exports.decimalFormat = decimalFormat
</wxs>
\ No newline at end of file
......@@ -23,21 +23,25 @@ Page({
name: "公司介绍",
icon: "icon-company",
icon1: "icon-company1",
isShow: true
},
{
name: "方案介绍",
icon: "icon-product",
icon1: "icon-product1",
isShow: true
},
{
name: "视频直播",
icon: "icon-video",
icon1: "icon-video",
isShow: true
},
{
name: "展业测算",
icon: "icon-measure",
icon1: "icon-measure",
isShow: false
},
],
curTabIndex: 0,
......@@ -392,6 +396,10 @@ Page({
},
// 获取员工名片信息
getCardDetail() {
console.log(wx.showMeasure)
this.setData({
'tabList[3].isShow': wx.showMeasure
})
console.log(util.getStorageSync('scene'), wx.$trackData.cardId)
const scene = util.getStorageSync('scene');
let params = {
......
......@@ -12,7 +12,7 @@
<!-- tab介绍 -->
<view class="tab-list">
<block wx:for="{{tabList}}" wx:key="index">
<view class="tab-item {{curTabIndex === index ? 'tab-item-active' : '' }}" style="width: {{100 / tabList.length + '%'}}" data-name="{{item}}" data-index="{{index}}" bindtap="introduce">
<view wx:if="{{item.isShow}}" class="tab-item {{curTabIndex === index ? 'tab-item-active' : '' }}" data-name="{{item}}" data-index="{{index}}" bindtap="introduce">
<image wx:if="{{curTabIndex !== index}}" class="tab-img" mode="widthFix" webp src="{{IMGURL}}home/{{item.icon1}}.png?v={{img_version}}"></image>
<image wx:else class="tab-img" mode="widthFix" webp src="{{IMGURL}}home/{{item.icon}}.png?v={{img_version}}"></image>
<view class="tab-text">{{item.name}}</view>
......
......@@ -383,6 +383,69 @@ const getScopeTime = (inputTime, curTime) => {
}
return obj.text
}
const deepClone = (target) => {
const map = new WeakMap()
function isObject(target) {
return (typeof target === 'object' && target ) || typeof target === 'function'
}
function clone(data) {
if (!isObject(data)) {
return data
}
if ([Date, RegExp].includes(data.constructor)) {
return new data.constructor(data)
}
if (typeof data === 'function') {
return new Function('return ' + data.toString())()
}
const exist = map.get(data)
if (exist) {
return exist
}
if (data instanceof Map) {
const result = new Map()
map.set(data, result)
data.forEach((val, key) => {
if (isObject(val)) {
result.set(key, clone(val))
} else {
result.set(key, val)
}
})
return result
}
if (data instanceof Set) {
const result = new Set()
map.set(data, result)
data.forEach(val => {
if (isObject(val)) {
result.add(clone(val))
} else {
result.add(val)
}
})
return result
}
const keys = Reflect.ownKeys(data)
const allDesc = Object.getOwnPropertyDescriptors(data)
const result = Object.create(Object.getPrototypeOf(data), allDesc)
map.set(data, result)
keys.forEach(key => {
const val = data[key]
if (isObject(val)) {
result[key] = clone(val)
} else {
result[key] = val
}
})
return result
}
return clone(target)
}
const Util = {
setNavigationBarTitleText,
getNavigationBarTitleText,
......@@ -415,5 +478,6 @@ const Util = {
throttle,
decimal,
timeago,
deepClone
}
export default Util
\ 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!