Browse Source

广告,多产品展示

master
caichunsheng 4 years ago
parent
commit
456f0e8461
  1. 12
      pages/component/TitleHeader.js
  2. 10
      pages/index/index.js
  3. 31
      pages/info/sceneProductInfo/index.js
  4. 33
      pages/info/sceneProductInfo/index.wxml

12
pages/component/TitleHeader.js

@ -75,15 +75,17 @@ Component({
}) })
} }
else if (pages[pages.length-1].route.indexOf('orderList') != -1){ else if (pages[pages.length-1].route.indexOf('orderList') != -1){
console.log(11111);
wx.navigateTo({ wx.navigateTo({
url: '/pages/user/cartlist/list' url: '/pages/user/cartlist/list'
}) })
} }
else if (pages[pages.length-1].route.indexOf('scene') != -1){ // else if (pages[pages.length-1].route.indexOf('scene') != -1){
wx.reLaunch({ // console.log(22222);
url: "/pages/user/cartlist/list" // wx.reLaunch({
}) // url: "/pages/user/cartlist/list"
} // })
// }
else if (pages.length>1){ else if (pages.length>1){
wx.navigateBack({ wx.navigateBack({
delta: 1 delta: 1

10
pages/index/index.js

@ -371,7 +371,7 @@ Page({
event: e.currentTarget.dataset.event event: e.currentTarget.dataset.event
}, 1) }, 1)
} }
let url = e.currentTarget.dataset.url; let url = e.currentTarget.dataset.tdata.url;
app.globalData.weburl = url; app.globalData.weburl = url;
wx.navigateTo({ wx.navigateTo({
url: "/pages/pbService/web/index" url: "/pages/pbService/web/index"
@ -490,7 +490,7 @@ Page({
if ((item.tdata.url.indexOf('http://') != -1 || item.tdata.url.indexOf('https://') != -1) && item.tdata.url.indexOf('m.cloud.sz-trip.com') == -1) { if ((item.tdata.url.indexOf('http://') != -1 || item.tdata.url.indexOf('https://') != -1) && item.tdata.url.indexOf('m.cloud.sz-trip.com') == -1) {
// 外部h5 // 外部h5
console.log(item.tdata) console.log(item.tdata)
app.globalData.weburl = item.tdata; app.globalData.weburl = item.tdata.url;
wx.navigateTo({ wx.navigateTo({
url: "/pages/pbService/web/index" url: "/pages/pbService/web/index"
}) })
@ -510,7 +510,7 @@ Page({
url: url, url: url,
}) })
} else { } else {
app.globalData.weburl = item.tdata; app.globalData.weburl = item.tdata.url;
wx.navigateTo({ wx.navigateTo({
url: "/pages/pbService/web/index" url: "/pages/pbService/web/index"
}) })
@ -655,7 +655,7 @@ Page({
if ((item.tdata.url.indexOf('http://') != -1 || item.tdata.url.indexOf('https://') != -1) && item.tdata.url.indexOf('m.cloud.sz-trip.com') == -1) { if ((item.tdata.url.indexOf('http://') != -1 || item.tdata.url.indexOf('https://') != -1) && item.tdata.url.indexOf('m.cloud.sz-trip.com') == -1) {
// 外部h5 // 外部h5
console.log(item.tdata) console.log(item.tdata)
app.globalData.weburl = item.tdata; app.globalData.weburl = item.tdata.url;
wx.navigateTo({ wx.navigateTo({
url: "/pages/pbService/web/index" url: "/pages/pbService/web/index"
}) })
@ -675,7 +675,7 @@ Page({
url: url, url: url,
}) })
} else { } else {
app.globalData.weburl = item.tdata; app.globalData.weburl = item.tdata.url;
wx.navigateTo({ wx.navigateTo({
url: "/pages/pbService/web/index" url: "/pages/pbService/web/index"
}) })

31
pages/info/sceneProductInfo/index.js

@ -31,7 +31,8 @@ Page({
cartCount: 0, cartCount: 0,
cartImgInfo: null, cartImgInfo: null,
cartTop: 0, cartTop: 0,
top: 0 top: 0,
skuList:[],//立即预定的列表
}, },
/** /**
@ -96,7 +97,16 @@ Page({
this.setData({ this.setData({
info: res.data info: res.data
}) })
var arr = []
console.log(this.data.info); console.log(this.data.info);
res.data.product.forEach(item => {
item.sku.forEach(itemB=>{
arr.push(itemB)
})
});
this.setData({
skuList:arr
})
util.pagePoint({ event: 'scene_view', param: { type: res.data.type, id: res.data.id } }, 1) util.pagePoint({ event: 'scene_view', param: { type: res.data.type, id: res.data.id } }, 1)
this.BroswerRecord() this.BroswerRecord()
}) })
@ -118,7 +128,6 @@ Page({
this.setData({ this.setData({
ask: res.data.rows ask: res.data.rows
}) })
console.log(res)
}) })
// 获取评价列表 // 获取评价列表
commonApi._post("scene/get_comment", { commonApi._post("scene/get_comment", {
@ -171,7 +180,6 @@ Page({
}, },
like: function () { like: function () {
let id = this.data.id, isLike = Number(this.data.isLike); let id = this.data.id, isLike = Number(this.data.isLike);
console.log(isLike)
commonApi.user_post(isLike != 1 ? "scene/scene_collection" : "scene/scene_cancel_collection", { commonApi.user_post(isLike != 1 ? "scene/scene_collection" : "scene/scene_cancel_collection", {
scene_id: id scene_id: id
}).then(res => { }).then(res => {
@ -237,14 +245,12 @@ Page({
// }) // })
// }, // },
selectSku: function (e) { selectSku: function (e) {
console.log(e)
let index = e.currentTarget.dataset.index; let index = e.currentTarget.dataset.index;
this.setData({ this.setData({
skuIndex: index skuIndex: index
}) })
}, },
order: function (e) { order: function (e) {
console.log(e,e.currentTarget.dataset.product.sku[this.data.skuIndex])
// console.log(this.data.info,this.data.skuFlag) // console.log(this.data.info,this.data.skuFlag)
app.globalData.postProduct = [] app.globalData.postProduct = []
app.globalData.list = [] app.globalData.list = []
@ -262,15 +268,19 @@ Page({
app.globalData.couponInfo = null; app.globalData.couponInfo = null;
app.globalData.retailId = this.data.retailId; app.globalData.retailId = this.data.retailId;
// let sku = e.currentTarget.dataset.sku,product = e.currentTarget.dataset.product; // let sku = e.currentTarget.dataset.sku,product = e.currentTarget.dataset.product;
let sku = {sku:e.currentTarget.dataset.product.sku[this.data.skuIndex]},product = {product: e.currentTarget.dataset.product} // let sku = {sku:e.currentTarget.dataset.product.sku[this.data.skuIndex]},product = {product: e.currentTarget.dataset.product}
let sku = {sku:this.data.skuList[this.data.skuIndex]},product = {product: e.currentTarget.dataset.product}
app.globalData.product = {...sku,...product} app.globalData.product = {...sku,...product}
console.log(this.data.skuIndex);
console.log(app.globalData.product);
// app.globalData.product = e.currentTarget.dataset; // app.globalData.product = e.currentTarget.dataset;
wx.navigateTo({ wx.navigateTo({
url: '/pages/order/scene/index', url: '/pages/order/scene/index',
}) })
}else { }else {
console.log('111');
commonApi.user_post("cart/add_sku", { commonApi.user_post("cart/add_sku", {
sku_id: this.data.info.product[0].sku[this.data.skuIndex].id, sku_id: this.data.skuList[this.data.skuIndex].id,
num: this.data.producNum num: this.data.producNum
}).then(res => { }).then(res => {
if (res.code == 1) { if (res.code == 1) {
@ -280,7 +290,6 @@ Page({
}) })
}) })
// 加动效 // 加动效
console.log(this.data.skuIndex)
this.setData({ this.setData({
skuFlag: null, skuFlag: null,
aniSkuIndex: this.data.skuIndex, aniSkuIndex: this.data.skuIndex,
@ -573,7 +582,6 @@ Page({
}, },
//加入购物车 //加入购物车
showCart: function () { showCart: function () {
console.log(this.data)
if (this.data.info.product[0].sku.length == 0) { if (this.data.info.product[0].sku.length == 0) {
wx.showToast({ wx.showToast({
title: '该产品未设置规格,不能加购', title: '该产品未设置规格,不能加购',
@ -586,7 +594,6 @@ Page({
}) })
let that = this let that = this
wx.createSelectorQuery().select('#skuImg').boundingClientRect(function (res) { wx.createSelectorQuery().select('#skuImg').boundingClientRect(function (res) {
console.log(res)
that.setData({ that.setData({
cartImgInfo: 'top:' + res.top + 'px;left:' + res.left + 'px;' cartImgInfo: 'top:' + res.top + 'px;left:' + res.left + 'px;'
}) })
@ -646,7 +653,6 @@ Page({
*/ */
onShow: function () { onShow: function () {
commonApi.user_post('cart/get_list', {}).then(res => { commonApi.user_post('cart/get_list', {}).then(res => {
console.log(res,res.data)
this.setData({ this.setData({
cartCount: res.data.length cartCount: res.data.length
}) })
@ -661,15 +667,12 @@ Page({
commonApi.user_post("product/getProductAllowancePrice", { commonApi.user_post("product/getProductAllowancePrice", {
product_code: this.data.product[0].product.product_code product_code: this.data.product[0].product.product_code
}).then(resTwo => { }).then(resTwo => {
console.log(resTwo)
if (resTwo && resTwo.code == 1) { if (resTwo && resTwo.code == 1) {
this.setData({ this.setData({
allowance_data: resTwo.data allowance_data: resTwo.data
}) })
let spread_price = Number(this.data.allowance_data.discount_limit_price - this.data.allowance_data.user_used_price) let spread_price = Number(this.data.allowance_data.discount_limit_price - this.data.allowance_data.user_used_price)
let sInfo = this.data.product[0].sku let sInfo = this.data.product[0].sku
console.log(9999, this.data.allowance_data.discount_rate / 100 * sInfo.price)
console.log(9999, spread_price)
if (spread_price > 0) { if (spread_price > 0) {
if (spread_price < this.data.allowance_data.discount_rate / 100 * sInfo.price) { if (spread_price < this.data.allowance_data.discount_rate / 100 * sInfo.price) {
this.setData({ this.setData({

33
pages/info/sceneProductInfo/index.wxml

@ -79,7 +79,7 @@
<image src="https://sz-qd.oss-cn-hangzhou.aliyuncs.com/xcxImages/info/cart.png" mode="widthFix"></image> <image src="https://sz-qd.oss-cn-hangzhou.aliyuncs.com/xcxImages/info/cart.png" mode="widthFix"></image>
<view class="cart-num">{{cartCount}}</view> <view class="cart-num">{{cartCount}}</view>
</navigator> </navigator>
<view class="mask" wx:if="{{skuFlag}}"> <!-- <view class="mask" wx:if="{{skuFlag}}">
<view class="mask-bg" bindtap="hideSku"></view> <view class="mask-bg" bindtap="hideSku"></view>
<view class="mask-content"> <view class="mask-content">
<view class="iconfont icon-close" bindtap="hideSku"></view> <view class="iconfont icon-close" bindtap="hideSku"></view>
@ -109,6 +109,37 @@
<view class="mask-btn disable" wx:else>该商品已下架</view> <view class="mask-btn disable" wx:else>该商品已下架</view>
</view> </view>
</view> </view>
</view> -->
<view class="mask" wx:if="{{skuFlag}}">
<view class="mask-bg" bindtap="hideSku"></view>
<view class="mask-content">
<view class="iconfont icon-close" bindtap="hideSku"></view>
<view class="sku-info-box">
<image id="skuImg" src="{{info.headimg}}" mode="aspectFill"></image>
<view class="sku-info">
<view class="sku-price">{{skuList[skuIndex].price/100}}
<view class="allowance" wx:if="{{allowance_data}}">
补贴价:¥{{ (1 - allowance_data.discount_rate / 100) * info.sku[skuIndex].price / 100 }}</view>
</view>
<view class="sku-name">已选择:{{skuList[skuIndex].sku_name}}</view>
</view>
</view>
<view class="sku-names">
<view bindtap="selectSku" data-index="{{index}}" class="sku-name-item textOver{{index==skuIndex?' active':''}}" wx:for="{{skuList}}">{{item.sku_name}}</view>
</view>
<view class="number-box">
<text>数量</text>
<view class="iconfont icon-sami-select" bindtap="minus"></view>
<view class="number">{{producNum}}</view>
<view class="iconfont icon-add-select" bindtap="add"></view>
</view>
<view style="height:138rpx"></view>
<view class="btn-box">
<view class="mask-btn" bindtap="order" data-sku="{{sku}}" data-product="{{item}}" wx:if="{{info && info.flag==1}}" data-disable="{{item.flag==0 || sku.flag=='off'?1:0}}" data-disable="{{item.flag==0 || sku.flag=='off'?1:0}}">{{skuFlag=='cart'?'确认':'立即购买'}}
</view>
<view class="mask-btn disable" wx:else>该商品已下架</view>
</view>
</view>
</view> </view>
<!-- <view class="empty-box"> <!-- <view class="empty-box">
<view>这里空空如也,快去向大家提问吧!</view> <view>这里空空如也,快去向大家提问吧!</view>

Loading…
Cancel
Save