Browse Source

image优化

master
xpz2018 6 years ago
parent
commit
6ed604d1bc
8 changed files with 88 additions and 58 deletions
  1. 58
      pages/mall/order-info/index.js
  2. 4
      pages/mall/order-offer/index.wxml
  3. 8
      pages/mall/order-offer/index.wxss
  4. 4
      pages/mall/search-list/index.wxml
  5. 8
      pages/mall/search-list/index.wxss
  6. 37
      pages/mall/shops/index.js
  7. 19
      pages/mall/shops/index.wxml
  8. 8
      pages/mall/shops/index.wxss

58
pages/mall/order-info/index.js

@ -79,8 +79,8 @@ Page({
});
},
tagClick: function (e) {
var sukId = e.currentTarget.dataset.suk
var id = e.currentTarget.dataset.index
var sukId = e.currentTarget.dataset.suk// 对应的是一级列表的Id
var id = e.currentTarget.dataset.index// 对应的是二级列表的Id,相应是有价格计算的
var attributeList = this.data.orderInfo.attributeList
for (let i = 0; i < attributeList.length; i++) {
if (attributeList[i].id == sukId) {
@ -93,43 +93,35 @@ Page({
}
}
}
if (this.data.sukList.length == 0) {
this.setData({
['orderInfo.attributeList']: attributeList,
amount: null
})
// 检查是否需要跟新,或者修改;
var push_flag = true
for (let index = 0; index < this.data.sukList.length; index++) {
const element = this.data.sukList[index];
if (element.skuId == sukId) {
this.data.sukList[index].id = id
push_flag = false
break
}
}
if(push_flag){
this.data.sukList.push({
skuId: sukId,
id: id
})
this.setData({
['orderInfo.attributeList']: attributeList
})
} else {
}
if (this.data.sukList.length == this.data.orderInfo.attributeList.length) {
var match = {}
for (let index = 0; index < this.data.sukList.length; index++) {
const element = this.data.sukList[index];
if (element.skuId == sukId) {
this.data.sukList[index].id = id
this.setData({
['orderInfo.attributeList']: attributeList
})
return
}
}
this.data.sukList.push({
skuId: sukId,
id: id
})
this.setData({
['orderInfo.attributeList']: attributeList
})
if (this.data.sukList.length == this.data.orderInfo.attributeList.length) {
var match = {}
for (let index = 0; index < this.data.sukList.length; index++) {
const element = this.data.sukList[index];
match[element.skuId] = element.id
}
this.data.skuJson = JSON.stringify(match)
this.data.skuJson = this.data.skuJson.substring(1, this.data.skuJson.length - 1)
this.onNumChange(null)
match[element.skuId] = element.id
}
this.data.skuJson = JSON.stringify(match)
this.data.skuJson = this.data.skuJson.substring(1, this.data.skuJson.length - 1)
this.onNumChange(null)
}
},
// 数量变化的函数监听
@ -152,6 +144,8 @@ Page({
this.data.form.unitPrice = Number(element.price)
this.data.form.dividePrice = Number(element.dividePrice)
this.data.form.skuId = element.id
console.log(element)
break
}
}
// 如果查询到了价格,进行价格计算

4
pages/mall/order-offer/index.wxml

@ -28,7 +28,9 @@
<view class="margin-top header-box" style="padding:32rpx">
<view class="flex content">
<wux-image shape="offer" width="{{60}}" height="{{60}}" src="{{form.litimgUrl}}">
<text class="icon--refresher" slot="loading"></text>
<view class="image-load" slot="loading">
<text class="icon--refresher"></text>
</view>
</wux-image>
<view style="flex:1;margin-left:24rpx">
<view class="page-name">{{form.name}}</view>

8
pages/mall/order-offer/index.wxss

@ -74,4 +74,12 @@
button::after {
border: none;
}
.image-load {
width: 120rpx;
height: 120rpx;
display: flex;
align-items: center;
justify-content: center;
}

4
pages/mall/search-list/index.wxml

@ -40,7 +40,9 @@
<view wx:for-item="pageItem" wx:for-index="pageIndex" wx:for="{{taskList}}" wx:key="pageIndex">
<view class="flex content" wx:for="{{pageItem}}" wx:key="index" data-page="{{pageIndex}}" data-index="{{index}}" bindtap="lookItem">
<wux-image width="{{120}}" height="{{120}}" wux-class="page-icon" src="{{item.litimgUrl}}" mode="{{aspectFill}}">
<text class="icon--refresher" slot="loading"></text>
<view class="image-load" slot="loading">
<text class="icon--refresher"></text>
</view>
</wux-image>
<view style="flex:1;padding:16rpx">
<view class="flex flex-justify">

8
pages/mall/search-list/index.wxss

@ -84,3 +84,11 @@
color: rgba(153, 153, 153, 1);
line-height: 14px;
}
.image-load {
width: 240rpx;
height: 240rpx;
display: flex;
align-items: center;
justify-content: center;
}

37
pages/mall/shops/index.js

@ -32,15 +32,16 @@ Page({
this.checkLogin()
this.setData({
height: app.globalData.fragmentHeight,
CustomBar: app.globalData.CustomBar
CustomBar: app.globalData.CustomBar,
token: app.globalData.token
})
event.on('EventMessage', this, this.onEvent)
},
// 事件通知
onEvent: function (message) {
console.log('mall>>index>>onEvent', message)
console.log('shops>>index>>onEvent', message)
if(message.what == 1 && util.isEmpty(this.data.token)){
// this.setData({ token: app.globalData.token })
this.setData({ token: app.globalData.token })
}
},
/**
@ -48,33 +49,37 @@ Page({
*/
onReady: function () {
if (!this.data.firstShow) {
this.setData({
token: app.globalData.token
})
this.fetchCheapList()
this.fetchTaskList()
}
},
onRefreshList: function(){
this.setData({
cheapList: [],
taskList: [],
['form.pageNum']: 1,
loading: true,
finished: false
})
this.fetchCheapList()
this.fetchTaskList()
},
// 获取特价列表
fetchCheapList: function () {
request.get('/bxe-mall/product/cheapList').then(result => {
//成功回调
this.setData({ loading: false, cheapList: result.data })
}).catch(err => {
//异常回调
this.setData({ loading: false })
util.showToast(err)
})
},
// 获取团购列表
fetchTaskList: function () {
if (this.data.requesting || this.data.finished) {
return
}
if (this.data.form.pageNum == 1 && this.data.taskList.length == 0) {
this.setData({ loading: true })
}
this.data.requesting = true
// /product/cheapList特价产品列表
request.get('/bxe-mall/product/groupList', this.data.form).then(result => {
@ -98,20 +103,20 @@ Page({
util.showToast(err)
})
},
// 进入搜索页
searchList: function (e) {
wx.navigateTo({
url: '/pages/mall/search-list/index'
})
},
// 查看团购Item
lookGroupItem: function (e) {
var item = this.data.taskList[e.currentTarget.dataset.page][e.currentTarget.dataset.index]
wx.navigateTo({
url: '/pages/mall/order-info/index?id=' + item.id
})
},
// 查看特价Item
lookCheapItem: function (e) {
var item = this.data.cheapList[e.currentTarget.dataset.index]
wx.navigateTo({

19
pages/mall/shops/index.wxml

@ -96,10 +96,11 @@
<view class="nav-title">限时限量 售完即止</view>
</view>
<view class="flex content" wx:for="{{cheapList}}" wx:key="index" data-index="{{index}}" bindtap="lookCheapItem">
<image class="page-icon" src="{{item.litimgUrl}}" lazy-load="{{true}}" mode="aspectFill"></image>
<!-- <wux-image width="{{119}}" height="{{119}}" wux-class="page-icon" src="{{item.litimgUrl}}" mode="{{aspectFill}}">
<text class="icon--refresher" slot="loading"></text>
</wux-image> -->
<wux-image width="{{119}}" height="{{119}}" wux-class="page-icon" lazyLoad="true" src="{{item.litimgUrl}}" mode="aspectFill">
<view class="image-load" slot="loading">
<text class="icon--refresher"></text>
</view>
</wux-image>
<view style="flex:1;padding:16rpx 20rpx">
<view class="flex flex-justify">
<view class="page-name">{{item.name}}</view>
@ -124,10 +125,12 @@
</view>
<view wx:for-item="pageItem" wx:for-index="pageIndex" wx:for="{{taskList}}" wx:key="pageIndex">
<view class="flex content" wx:for="{{pageItem}}" wx:key="index" data-page="{{pageIndex}}" data-index="{{index}}" bindtap="lookGroupItem">
<image class="page-icon" src="{{item.litimgUrl}}" lazy-load="{{true}}" mode="aspectFill"></image>
<!-- <wux-image width="{{120}}" height="{{120}}" wux-class="page-icon" src="{{item.litimgUrl}}" mode="{{aspectFill}}">
<text class="icon--refresher" slot="loading"></text>
</wux-image> -->
<!-- <image class="page-icon" src="{{item.litimgUrl}}" lazy-load="{{true}}" mode="aspectFill"></image> -->
<wux-image width="{{120}}" height="{{120}}" lazyLoad="{{true}}" wux-class="page-icon" src="{{item.litimgUrl}}" mode="aspectFill">
<view class="image-load" slot="loading">
<text class="icon--refresher"></text>
</view>
</wux-image>
<view style="flex:1;padding:16rpx 20rpx">
<view class="flex flex-justify">
<view class="page-name">{{item.name}}</view>

8
pages/mall/shops/index.wxss

@ -125,4 +125,12 @@
font-weight: 400;
color: rgba(153, 153, 153, 1);
line-height: 14px;
}
.image-load {
width: 240rpx;
height: 240rpx;
display: flex;
align-items: center;
justify-content: center;
}
Loading…
Cancel
Save