Commit 96c262fe by 匡雅琴

页面跳转

1 parent a16aad0c
// pages/addValue/addValue/addValue.js
import Util from '../../../utils/util'
import pageData from '../constant/data'
import Util from "../../../utils/util";
import pageData from "../constant/data";
Page({
/**
* 页面的初始数据
......@@ -11,205 +11,203 @@ Page({
tabActive: 2,
typeObj: {
service: {
name: '服务类',
class: 'service-color'
name: "服务类",
class: "service-color",
},
membrane: {
name: '膜类',
class: 'membrane-color'
name: "膜类",
class: "membrane-color",
},
beauty: {
name: '美容类',
class: 'beauty-color'
name: "美容类",
class: "beauty-color",
},
light: {
name: '轻改类',
class: 'light-color'
}
name: "轻改类",
class: "light-color",
},
},
formData: {
sales: 100,
flow: 100
flow: 100,
},
productList: [],
isReset: false,
hasPhoneNumber: false
hasPhoneNumber: false,
},
// tab切换
tabChange(e) {
console.log(e)
const index = e.currentTarget.dataset.index
console.log(e);
const index = e.currentTarget.dataset.index;
this.setData({
tabActive: index,
showPlay: false
})
showPlay: false,
});
},
// 提交测算
submit(e) {
console.log(e)
let sales = e ? +e.detail.value.sales : this.data.formData.sales
let flow = e ? +e.detail.value.flow : this.data.formData.flow
const _this = this
console.log(e);
let sales = e ? +e.detail.value.sales : this.data.formData.sales;
let flow = e ? +e.detail.value.flow : this.data.formData.flow;
const _this = this;
this.data.tabList.forEach((item, index) => {
item.productList.forEach((i, lastIndex) => {
if (i.profit) {
let name = `tabList[${index}].productList[${lastIndex}].profit`
let profit = _this.formula(i.productType, sales, flow)
let name = `tabList[${index}].productList[${lastIndex}].profit`;
let profit = _this.formula(i.productType, sales, flow);
this.setData({
[name]: profit
})
[name]: profit,
});
}
})
})
});
});
this.setData({
visible: false
})
visible: false,
});
},
// 计算公式,参数:productType
formula(productType, sales, flow) {
let profit = 0
switch(productType) {
case 'benefitCard':
let profit = 0;
switch (productType) {
case "benefitCard":
// 数字无忧权益卡
profit = (sales * 0.5 * 2000 * 12).toFixed(0)
break
case 'sunMembrane':
profit = (sales * 0.5 * 2000 * 12).toFixed(0);
break;
case "sunMembrane":
// 汽车太阳膜
profit = (flow * 0.05 * 5000 * 12).toFixed(0)
break
case 'protectMembrane':
profit = (flow * 0.05 * 5000 * 12).toFixed(0);
break;
case "protectMembrane":
// 漆面保护膜
profit = (flow * 0.15 * 12000 * 12).toFixed(0)
break
case 'colorMembrane':
profit = (flow * 0.15 * 12000 * 12).toFixed(0);
break;
case "colorMembrane":
// 改色膜
profit = (flow * 0.05 * 5000 * 12).toFixed(0)
break
case 'digitBeauty':
profit = (flow * 0.05 * 5000 * 12).toFixed(0);
break;
case "digitBeauty":
// 数字化美容
profit = (sales * 0.2 * 300 * 12).toFixed(0)
break
case 'chair':
profit = (sales * 0.2 * 300 * 12).toFixed(0);
break;
case "chair":
// 座椅通风
profit = (flow * 2580 * 0.9 * 0.01).toFixed(0)
break
case 'ar':
profit = (flow * 2580 * 0.9 * 0.01).toFixed(0);
break;
case "ar":
// AR导航
profit = (flow * 1680 * 0.9 * 0.015).toFixed(0)
break
case 'lamp':
profit = (flow * 1680 * 0.9 * 0.015).toFixed(0);
break;
case "lamp":
// 氛围灯
profit = (flow * 2680 * 0.9 * 0.015).toFixed(0)
break
case 'navigation':
profit = (flow * 2680 * 0.9 * 0.015).toFixed(0);
break;
case "navigation":
// 360全景导航
profit = (flow * 2880 * 0.9 * 0.015).toFixed(0)
break
profit = (flow * 2880 * 0.9 * 0.015).toFixed(0);
break;
}
console.log(profit.length)
console.log(profit.length);
if (profit.length > 8) {
return (profit / 10000).toFixed(0) + '万'
return (profit / 10000).toFixed(0) + "万";
} else {
return profit
return profit;
}
console.log(productType, sales, flow, profit)
return profit
console.log(productType, sales, flow, profit);
return profit;
},
reset() {
this.setData({
isReset: false,
formData: {
sales: 100,
flow: 100
}
})
flow: 100,
},
});
},
focus() {
this.setData({
isReset: true
})
return false
isReset: true,
});
return false;
},
// 显示测算弹窗
showCalculate() {
this.setData({
visible: !this.data.visible
})
visible: !this.data.visible,
});
},
clickDialog(e) {
console.log(e.changedTouches[0].clientY)
console.log(e.changedTouches[0].clientY);
if (e.changedTouches[0].clientY < 352) {
this.setData({
visible: false
})
visible: false,
});
}
},
// 跳转产品详情
goDetail(e) {
console.log(e.currentTarget.dataset.item, "===");
wx.navigateTo({
url: e.currentTarget.dataset.item,
});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.submit()
const userInfo = Util.getUserInfo()
console.log(userInfo)
this.submit();
const userInfo = Util.getUserInfo();
console.log(userInfo);
if (userInfo.phone) {
this.setData({
hasPhoneNumber: true,
productList: this.data.tabList[this.data.tabActive].productList
})
productList: this.data.tabList[this.data.tabActive].productList,
});
} else {
this.setData({
productList: this.data.tabList[this.data.tabActive].productList.slice(0,2)
})
productList: this.data.tabList[this.data.tabActive].productList.slice(
0,
2
),
});
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
onReady() {},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
onShow() {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
onShareAppMessage() {},
});
......@@ -23,7 +23,7 @@
<view class="product-tips">预估收益根据您的新车销量 100台 测算所得</view>
<view class="product-list">
<block wx:for="{{productList}}" wx:key="ind">
<view class="product-item">
<view class="product-item" bindtap="goDetail" data-item="{{item.path}}">
<image webp src="{{IMGURL}}image/dijia/{{item.img}}.png"></image>
<view class="product-content">
<view class="product-type {{typeObj[item.type].class}}">{{typeObj[item.type].name}}</view>
......
......@@ -12,7 +12,8 @@ var tabList = [
// profit: '92.4万',
profit: '99999999万',
type: 'service',
productType: 'benefitCard'
productType: 'benefitCard',
path: '/productDetail/equity/equity'
},
{
img: 'product-img2',
......@@ -20,7 +21,8 @@ var tabList = [
price: '1500',
profit: '1008万',
type: 'membrane',
productType: 'sunMembrane'
productType: 'sunMembrane',
path: '/productDetail/solarFilm/solarFilm'
}
],
videoList: [
......@@ -63,7 +65,8 @@ var tabList = [
price: '12000',
profit: '216万',
type: 'membrane',
productType: 'protectMembrane'
productType: 'protectMembrane',
path: '/productDetail/paintProtect/paintProtect'
},
{
img: 'product-img4',
......@@ -71,7 +74,8 @@ var tabList = [
price: '5000',
profit: '30万',
type: 'membrane',
productType: 'colorMembrane'
productType: 'colorMembrane',
path: '/productDetail/changingFilm/changingFilm'
}
]
},
......@@ -87,7 +91,8 @@ var tabList = [
price: '300',
profit: '36万',
type: 'beauty',
productType: 'digitBeauty'
productType: 'digitBeauty',
path: '/productDetail/carBeauty/carBeauty'
},
{
img: 'product-img6',
......@@ -95,7 +100,8 @@ var tabList = [
price: '1500',
profit: '1008万',
type: 'light',
productType: 'chair'
productType: 'chair',
path: '/productDetail/seatVentilate/seatVentilate'
},
{
img: 'product-img7',
......@@ -103,7 +109,8 @@ var tabList = [
price: '1680',
profit: '22.68万',
type: 'light',
productType: 'ar'
productType: 'ar',
path: '/productDetail/arNavigation/arNavigation'
},
{
img: 'product-img8',
......@@ -111,7 +118,8 @@ var tabList = [
price: '2680',
profit: '36.18万',
type: 'light',
productType: 'lamp'
productType: 'lamp',
path: '/productDetail/ambientLighting/ambientLighting'
},
{
img: 'product-img9',
......@@ -119,7 +127,8 @@ var tabList = [
price: '2880',
profit: '38.88万',
type: 'service',
productType: 'navigation'
productType: 'navigation',
path: '/productDetail/navigationArround/navigationArround'
}
],
videoList: [
......@@ -157,7 +166,8 @@ var tabList = [
price: '300',
profit: '36万',
type: 'beauty',
productType: 'digitBeauty'
productType: 'digitBeauty',
path: '/productDetail/lossPhase/lossPhase'
},
{
img: 'product-img11',
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!