Commit 96c262fe by 匡雅琴

页面跳转

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