26 changed files with 2091 additions and 0 deletions
Unified View
Diff Options
-
1app.json
-
538submodel/pages/goods/create/index.js
-
7submodel/pages/goods/create/index.json
-
149submodel/pages/goods/create/index.wxml
-
31submodel/pages/goods/create/index.wxss
-
316submodel/pages/goods/detail/index.js
-
7submodel/pages/goods/detail/index.json
-
73submodel/pages/goods/detail/index.wxml
-
79submodel/pages/goods/detail/index.wxss
-
141submodel/pages/goods/fragment/index.js
-
15submodel/pages/goods/fragment/index.json
-
53submodel/pages/goods/fragment/index.wxml
-
0submodel/pages/goods/fragment/index.wxss
-
133submodel/pages/goods/goods.wxs
-
238submodel/pages/goods/index/index.js
-
10submodel/pages/goods/index/index.json
-
69submodel/pages/goods/index/index.wxml
-
51submodel/pages/goods/index/index.wxss
-
26submodel/pages/goods/product-item/index.js
-
6submodel/pages/goods/product-item/index.json
-
27submodel/pages/goods/product-item/index.wxml
-
49submodel/pages/goods/product-item/index.wxss
-
66submodel/pages/paper/index/index.js
-
3submodel/pages/paper/index/index.json
-
2submodel/pages/paper/index/index.wxml
-
1submodel/pages/paper/index/index.wxss
@ -0,0 +1,538 @@ |
|||||
|
import { |
||||
|
paperCategoryList, |
||||
|
getProductInfo, |
||||
|
createProductInfo, |
||||
|
updateProductInfo, |
||||
|
getWaterRate, |
||||
|
getDopantRate, |
||||
|
getBiddingInterval |
||||
|
} from "../../../../api/ztb" |
||||
|
import regions from '../../../../const/region' |
||||
|
const math = require('../../../../utils/math') |
||||
|
const util = require('../../../../utils/util') |
||||
|
const event = require('../../../../utils/event.js') |
||||
|
const app = getApp() |
||||
|
|
||||
|
Page({ |
||||
|
|
||||
|
/** |
||||
|
* 页面的初始数据 |
||||
|
*/ |
||||
|
data: { |
||||
|
safeBottom: app.globalData.safeBottom, |
||||
|
kg: app.globalData.kg, |
||||
|
height: app.globalData.safeFragmentHeight, |
||||
|
options: regions, |
||||
|
region: [440000, '', ''], |
||||
|
cateList: [], |
||||
|
dopantList: [], |
||||
|
waterList: [], |
||||
|
intervalList: [{ |
||||
|
text: '24小时', |
||||
|
value: 1 |
||||
|
}, { |
||||
|
text: '48小时', |
||||
|
value: 2 |
||||
|
}], |
||||
|
videoList: [], |
||||
|
imgLength: 0, |
||||
|
fileList: [], |
||||
|
form: { |
||||
|
bidType: 1, |
||||
|
imgList: [], |
||||
|
secondCategoryId: null, |
||||
|
stock: null, |
||||
|
dopantRate: null, |
||||
|
waterRate: null |
||||
|
}, |
||||
|
cateName: '', |
||||
|
dopantName: '', |
||||
|
waterName: '', |
||||
|
intervalName: '', |
||||
|
sumAmount: 0, |
||||
|
keyboard: 0, |
||||
|
toView: '', |
||||
|
focus: false, |
||||
|
picking: false |
||||
|
}, |
||||
|
/** |
||||
|
* 生命周期函数--监听页面加载 |
||||
|
*/ |
||||
|
onLoad: function (options) { |
||||
|
this.setData({ |
||||
|
['form.bidType']: options.type ? Number(options.type) : 1, |
||||
|
kg: app.globalData.kg, |
||||
|
safeBottom: app.globalData.safeBottom, |
||||
|
height: app.globalData.safeFragmentHeight |
||||
|
}) |
||||
|
this.cascaderView = this.cascaderView || this.selectComponent('#wux-cascader') |
||||
|
this.pickerView = this.pickerView || this.selectComponent('#picker-view') |
||||
|
wx.showLoading({ |
||||
|
title: '加载中', |
||||
|
mask: true |
||||
|
}) |
||||
|
getDopantRate().then(result => { |
||||
|
var list = [] |
||||
|
result.data.forEach((item) => { |
||||
|
list.push({ |
||||
|
text: item.name, |
||||
|
value: item.id |
||||
|
}) |
||||
|
}) |
||||
|
this.setData({ |
||||
|
dopantList: list |
||||
|
}) |
||||
|
}) |
||||
|
getWaterRate().then(result => { |
||||
|
var list = [] |
||||
|
result.data.forEach((item) => { |
||||
|
list.push({ |
||||
|
text: item.name, |
||||
|
value: item.id |
||||
|
}) |
||||
|
}) |
||||
|
this.setData({ |
||||
|
waterList: list |
||||
|
}) |
||||
|
}) |
||||
|
getBiddingInterval().then(result => { |
||||
|
var list = [] |
||||
|
result.data.forEach((item) => { |
||||
|
list.push({ |
||||
|
text: item.name, |
||||
|
value: item.id |
||||
|
}) |
||||
|
}) |
||||
|
this.setData({ |
||||
|
intervalList: list |
||||
|
}) |
||||
|
}) |
||||
|
paperCategoryList({ |
||||
|
type: 1 |
||||
|
}).then(result => { |
||||
|
var cateList = [] |
||||
|
result.data.forEach((item) => { |
||||
|
cateList.push({ |
||||
|
label: item.name, |
||||
|
value: item.id, |
||||
|
isLeaf: false, |
||||
|
}) |
||||
|
}) |
||||
|
this.setData({ |
||||
|
cateList: cateList |
||||
|
}) |
||||
|
if (!options.id) { |
||||
|
wx.hideLoading() |
||||
|
} |
||||
|
}).catch(err => { |
||||
|
//异常回调
|
||||
|
if (!options.id) { |
||||
|
wx.hideLoading() |
||||
|
} |
||||
|
}) |
||||
|
if (options.id) { |
||||
|
getProductInfo(options.id).then(result => { |
||||
|
var fileList = [] |
||||
|
if (result.data.imgList && result.data.imgList.length) { |
||||
|
result.data.imgList.forEach(element => { |
||||
|
fileList.push({ |
||||
|
url: element, |
||||
|
status: 8 |
||||
|
}) |
||||
|
}) |
||||
|
} |
||||
|
var videoList = [] |
||||
|
if (result.data.videoUrl) { |
||||
|
videoList.push({ |
||||
|
videoUrl: result.data.videoUrl, |
||||
|
status: 8 |
||||
|
}) |
||||
|
} |
||||
|
var region = [] |
||||
|
if (result.data.locDistrictId) { |
||||
|
region[0] = parseInt(result.data.locDistrictId / 10000) * 10000 |
||||
|
region[1] = parseInt(result.data.locDistrictId / 100) * 100 |
||||
|
region[2] = parseInt(result.data.locDistrictId) |
||||
|
} |
||||
|
this.data.cateName = result.data.firstCategoryName + ' ' + result.data.secondCategoryName |
||||
|
if (this.data.dopantList && this.data.dopantList.length) { |
||||
|
this.data.dopantList.forEach(element => { |
||||
|
if (Number(element.value) == Number(result.data.dopantRate)) { |
||||
|
this.data.dopantName = element.text |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
if (this.data.waterList && this.data.waterList.length) { |
||||
|
this.data.waterList.forEach(element => { |
||||
|
if (Number(element.value) == Number(result.data.waterRate)) { |
||||
|
this.data.waterName = element.text |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
if (result.data.biddingInterval) { |
||||
|
this.data.intervalList.forEach(element => { |
||||
|
if (Number(element.value) == Number(result.data.biddingInterval)) { |
||||
|
this.data.intervalName = element.text |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
if (result.data.unitPrice) { |
||||
|
var unitPrice = app.globalData.kg ? result.data.unitPrice : math.times(result.data.unitPrice, 1000) |
||||
|
} else { |
||||
|
var unitPrice = '' |
||||
|
} |
||||
|
|
||||
|
var stock = app.globalData.kg ? result.data.stock : math.divide(result.data.stock, 1000) |
||||
|
var lowestNum = '' |
||||
|
if (!util.isEmpty(result.data.lowestNum)) { |
||||
|
lowestNum = app.globalData.kg ? result.data.lowestNum : math.divide(result.data.lowestNum, 1000) |
||||
|
} |
||||
|
this.setData({ |
||||
|
form: result.data, |
||||
|
['form.unitPrice']: unitPrice, |
||||
|
['form.stock']: stock, |
||||
|
['form.lowestNum']: lowestNum, |
||||
|
fileList: fileList, |
||||
|
videoList: videoList, |
||||
|
region: region, |
||||
|
['form.areaStr']: result.data.locProvinceName + ' ' + result.data.locCityName + ' ' + result.data.locDistrictName, |
||||
|
cateValue: [result.data.firstCategoryId, result.data.secondCategoryId], |
||||
|
cateName: this.data.cateName, |
||||
|
dopantName: this.data.dopantName, |
||||
|
waterName: this.data.waterName, |
||||
|
imgLength: fileList.length, |
||||
|
intervalName: this.data.intervalName |
||||
|
}) |
||||
|
if (util.isEmpty(this.data.form.areaStr)) { |
||||
|
this.cascaderView.getCurrentOptions(region, true) |
||||
|
} |
||||
|
this.sumAmount(null) |
||||
|
this.data.form['coverImgUrl'] = fileList[0].url |
||||
|
wx.hideLoading() |
||||
|
}).catch(err => { |
||||
|
//异常回调
|
||||
|
wx.hideLoading() |
||||
|
util.showToast(err) |
||||
|
}) |
||||
|
} |
||||
|
}, |
||||
|
InputFocus(e) { |
||||
|
this.setData({ |
||||
|
focus: true, |
||||
|
toView: 'textarea', |
||||
|
keyboard: e.detail.height |
||||
|
}) |
||||
|
}, |
||||
|
InputBlur(e) { |
||||
|
this.setData({ |
||||
|
keyboard: 0, |
||||
|
focus: false, |
||||
|
toView: null |
||||
|
}) |
||||
|
}, |
||||
|
textareaFocus: function (e) { |
||||
|
this.setData({ |
||||
|
focus: true, |
||||
|
toView: 'textarea' |
||||
|
}) |
||||
|
}, |
||||
|
onVideoChange: function (e) { |
||||
|
if (e.detail && e.detail.length) { |
||||
|
this.data.form['videoUrl'] = e.detail[0].url |
||||
|
} |
||||
|
}, |
||||
|
onImageChange: function (e) { |
||||
|
if (e.detail) { |
||||
|
var list = [] |
||||
|
e.detail.forEach(element => { |
||||
|
if (!util.isEmpty(element.url)) { |
||||
|
list.push(element.url) |
||||
|
} |
||||
|
}) |
||||
|
this.data.form['imgList'] = list |
||||
|
this.setData({ |
||||
|
imgLength: list.length |
||||
|
}) |
||||
|
} |
||||
|
}, |
||||
|
bindInput: function (e) { |
||||
|
if (e.target.id == 'description') { |
||||
|
this.setData({ |
||||
|
['form.' + e.target.id]: e.detail.value |
||||
|
}) |
||||
|
} else { |
||||
|
this.data.form[e.target.id] = e.detail.value |
||||
|
} |
||||
|
}, |
||||
|
onLoadOptions: function (e) { |
||||
|
// /paperCategoryList 获取纸品列表
|
||||
|
const { |
||||
|
value |
||||
|
} = e.detail |
||||
|
const options = [...this.data.cateList] |
||||
|
var typeId = parseInt(value[value.length - 1]) |
||||
|
wx.showLoading({ |
||||
|
title: '加载中', |
||||
|
mask: true |
||||
|
}) |
||||
|
paperCategoryList({ |
||||
|
type: 2, |
||||
|
firstCategoryId: typeId |
||||
|
}).then(result => { |
||||
|
//成功回调
|
||||
|
var list = [] |
||||
|
result.data.forEach((item) => { |
||||
|
list.push({ |
||||
|
label: item.name, |
||||
|
value: item.id |
||||
|
}) |
||||
|
}) |
||||
|
options.forEach((element) => { |
||||
|
if (parseInt(element.value) === typeId) { |
||||
|
element.children = list |
||||
|
} |
||||
|
}) |
||||
|
this.setData({ |
||||
|
cateList: options |
||||
|
}) |
||||
|
wx.hideLoading() |
||||
|
}).catch(err => { |
||||
|
//异常回调
|
||||
|
wx.hideLoading() |
||||
|
}) |
||||
|
}, |
||||
|
showRegion: function () { |
||||
|
if (this.data.disabled) { |
||||
|
return |
||||
|
} |
||||
|
this.cascaderView.showPicker(this.data.region) |
||||
|
this.setData({ |
||||
|
picking: true |
||||
|
}) |
||||
|
}, |
||||
|
onRegionInit: function (e) { |
||||
|
if (this.data.form.locDistrictId && e.detail.length == 3) { |
||||
|
this.setData({ |
||||
|
['form.areaStr']: e.detail.map((n) => n.label).join(' ') |
||||
|
}) |
||||
|
} |
||||
|
}, |
||||
|
onRegionChange: function (e) { |
||||
|
if (e.detail && e.detail.options) { |
||||
|
this.setData({ |
||||
|
['form.areaStr']: e.detail.options.map((n) => n.label).join(' '), |
||||
|
region: e.detail.value |
||||
|
}) |
||||
|
this.data.form['locProvinceId'] = e.detail.value[0] |
||||
|
this.data.form['locProvinceName'] = e.detail.options[0].label |
||||
|
this.data.form['locCityId'] = e.detail.value[1] |
||||
|
this.data.form['locCityName'] = e.detail.options[1].label |
||||
|
this.data.form['locDistrictId'] = e.detail.value[2] |
||||
|
this.data.form['locDistrictName'] = e.detail.options[2].label |
||||
|
} |
||||
|
this.setData({ |
||||
|
picking: false |
||||
|
}) |
||||
|
}, |
||||
|
showPaperPicker: function (e) { |
||||
|
this.setData({ |
||||
|
visible: true, |
||||
|
picking: true |
||||
|
}) |
||||
|
var list = [this.data.cateList[0].value] |
||||
|
if (!this.data.cateList[0].children) { |
||||
|
this.onLoadOptions({ |
||||
|
detail: { |
||||
|
value: list |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
}, |
||||
|
onCategory: function (e) { |
||||
|
this.setData({ |
||||
|
picking: false |
||||
|
}) |
||||
|
if (e.detail && e.detail.options) { |
||||
|
this.setData({ |
||||
|
cateName: e.detail.options.map((n) => n.label).join(' '), |
||||
|
cateValue: e.detail.value |
||||
|
}) |
||||
|
this.data.form['firstCategoryId'] = e.detail.value[0] |
||||
|
this.data.form['secondCategoryId'] = e.detail.value[1] |
||||
|
} |
||||
|
}, |
||||
|
onPaperChange: function (e) { |
||||
|
this.setData({ |
||||
|
picking: false |
||||
|
}) |
||||
|
if (!e.detail) { |
||||
|
return |
||||
|
} |
||||
|
if (e.detail.type == 0) { |
||||
|
this.data.form['secondCategoryId'] = e.detail.value |
||||
|
this.data.form['firstCategoryId'] = e.detail.value |
||||
|
this.setData({ |
||||
|
cateName: e.detail.text |
||||
|
}) |
||||
|
} else if (e.detail.type == 1) { |
||||
|
this.data.form['dopantRate'] = e.detail.value |
||||
|
this.setData({ |
||||
|
dopantName: e.detail.text |
||||
|
}) |
||||
|
} else if (e.detail.type == 2) { |
||||
|
this.data.form['waterRate'] = e.detail.value |
||||
|
this.setData({ |
||||
|
waterName: e.detail.text |
||||
|
}) |
||||
|
} else if (e.detail.type == 3) { |
||||
|
this.data.form['biddingInterval'] = e.detail.value |
||||
|
this.setData({ |
||||
|
intervalName: e.detail.text |
||||
|
}) |
||||
|
} |
||||
|
}, |
||||
|
bindinput: function (e) { |
||||
|
this.data.form[e.target.id] = e.detail.value |
||||
|
}, |
||||
|
sumAmount: function (e) { |
||||
|
if (Number(this.data.form.unitPrice) > 0 && parseInt(this.data.form.stock)) { |
||||
|
this.setData({ |
||||
|
sumAmount: math.times(this.data.form.unitPrice, this.data.form.stock) |
||||
|
}) |
||||
|
} |
||||
|
}, |
||||
|
templatDescription: function () { |
||||
|
|
||||
|
}, |
||||
|
showRadioPicker: function (e) { |
||||
|
if (e.currentTarget.id == 'dopantRate') { |
||||
|
this.pickerView.showPicker(this.data.dopantList, this.data.form.dopantRate, 1) |
||||
|
} else if (e.currentTarget.id == 'waterRate') { |
||||
|
this.pickerView.showPicker(this.data.waterList, this.data.form.waterRate, 2) |
||||
|
} else if (e.currentTarget.id == 'biddingInterval') { |
||||
|
this.pickerView.showPicker(this.data.intervalList, this.data.form.biddingInterval, 3) |
||||
|
} |
||||
|
this.setData({ |
||||
|
picking: true |
||||
|
}) |
||||
|
}, |
||||
|
submitForm: function () { |
||||
|
if (util.isEmpty(this.data.form.secondCategoryId)) { |
||||
|
util.showToast('请选择废纸品类') |
||||
|
return |
||||
|
} |
||||
|
if (this.data.form.bidType == 2) { |
||||
|
if (util.isEmpty(this.data.form.unitPrice)) { |
||||
|
if (this.data.form.bidType == 1) { |
||||
|
util.showToast('请输入商品单价') |
||||
|
} else { |
||||
|
util.showToast('请输入起拍单价') |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
if (app.globalData.kg) { |
||||
|
if (parseFloat(this.data.form.unitPrice) > 100) { |
||||
|
if (this.data.form.bidType == 1) { |
||||
|
util.showToast('请检查您输入的商品单价是否合理') |
||||
|
} else { |
||||
|
util.showToast('请检查您输入的起拍单价是否合理') |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
} else { |
||||
|
if (parseFloat(this.data.form.unitPrice) < 100) { |
||||
|
if (this.data.form.bidType == 1) { |
||||
|
util.showToast('请检查您输入的商品单价是否合理') |
||||
|
} else { |
||||
|
util.showToast('请检查您输入的起拍单价是否合理') |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
if (util.isEmpty(this.data.form.stock)) { |
||||
|
util.showToast('请输入库存') |
||||
|
return |
||||
|
} |
||||
|
if (util.isEmpty(this.data.form.biddingInterval) && this.data.form.bidType == 2) { |
||||
|
util.showToast('请选择竞价有效时') |
||||
|
return |
||||
|
} |
||||
|
if (util.isEmpty(this.data.form.dopantRate)) { |
||||
|
util.showToast('请选择含杂比例') |
||||
|
return |
||||
|
} |
||||
|
if (util.isEmpty(this.data.form.waterRate)) { |
||||
|
util.showToast('请选择湿水比例') |
||||
|
return |
||||
|
} |
||||
|
if (util.isEmpty(this.data.form.locDistrictId)) { |
||||
|
util.showToast('请选择店铺所在区域') |
||||
|
return |
||||
|
} |
||||
|
if (util.isEmpty(this.data.form.locDetails)) { |
||||
|
util.showToast('请输入店铺详细地址') |
||||
|
return |
||||
|
} |
||||
|
if (this.data.form.imgList.length < 2) { |
||||
|
util.showToast('请至少上传2张商品图片') |
||||
|
return |
||||
|
} |
||||
|
this.data.form['coverImgUrl'] = this.data.form.imgList[0] |
||||
|
if (util.isEmpty(this.data.form.description)) { |
||||
|
util.showToast('请输入商品描述') |
||||
|
return |
||||
|
} |
||||
|
this.setData({ |
||||
|
requesting: true |
||||
|
}) |
||||
|
wx.showLoading({ |
||||
|
title: '加载中', |
||||
|
mask: true |
||||
|
}) |
||||
|
if (!app.globalData.kg) { |
||||
|
if (this.data.form.unitPrice > 0) { |
||||
|
this.data.form.unitPrice = math.divide(this.data.form.unitPrice, 1000) |
||||
|
|
||||
|
} else { |
||||
|
this.data.form.unitPrice = '' |
||||
|
} |
||||
|
|
||||
|
this.data.form.stock = math.times(this.data.form.stock, 1000) |
||||
|
if (!util.isEmpty(this.data.form.lowestNum)) { |
||||
|
this.data.form.lowestNum = math.times(this.data.form.lowestNum, 1000) |
||||
|
} |
||||
|
} |
||||
|
if (this.data.form.productId) { |
||||
|
updateProductInfo(this.data.form).then(result => { |
||||
|
wx.hideLoading() |
||||
|
event.emit('EventMessage', { |
||||
|
what: 102, |
||||
|
desc: 'GoodsCreate' |
||||
|
}) |
||||
|
util.showBackToast('商品发布成功!') |
||||
|
}).catch(err => { |
||||
|
//异常回调
|
||||
|
wx.hideLoading() |
||||
|
this.setData({ |
||||
|
requesting: false |
||||
|
}) |
||||
|
util.showToast(err) |
||||
|
}) |
||||
|
} else { |
||||
|
createProductInfo(this.data.form).then(result => { |
||||
|
wx.hideLoading() |
||||
|
util.showBackToast('商品创建成功!') |
||||
|
}).catch(err => { |
||||
|
wx.hideLoading() |
||||
|
this.setData({ |
||||
|
requesting: false |
||||
|
}) |
||||
|
util.showToast(err) |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
}) |
||||
@ -0,0 +1,7 @@ |
|||||
|
{ |
||||
|
"usingComponents": { |
||||
|
"select-view": "/components/select-view/index", |
||||
|
"wux-cascader": "/components/cascader/index", |
||||
|
"wux-uploader": "/components/uploader/index" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,149 @@ |
|||||
|
<wxs module="goods" src="../../goods/goods.wxs"></wxs> |
||||
|
<cu-custom bgColor="bg-white" isBack="{{true}}"> |
||||
|
<view slot="content">{{form.bidType == 1 ? '我要卖货' : '发布竞价'}}</view> |
||||
|
</cu-custom> |
||||
|
|
||||
|
<scroll-view scroll-y="true" style="height: {{height}}rpx;" scroll-into-view="{{toView}}"> |
||||
|
<view style="display:{{!focus ? 'block' : 'none'}}"> |
||||
|
<view class="cu-bar bg-white margin-top"> |
||||
|
<view class="action text-bold" style="color:#333333">{{!disabled?'商品图片(至少上传2张)':'商品图片'}}</view> |
||||
|
<view class="action text-sg">{{imgLength}}{{!disabled? '/6':'张'}}</view> |
||||
|
</view> |
||||
|
<wux-uploader count="6" fileList="{{fileList}}" bindcustomevent="onImageChange"></wux-uploader> |
||||
|
</view> |
||||
|
<view style="display:{{!focus ? 'block' : 'none'}}"> |
||||
|
<view class="cu-bar bg-white margin-top"> |
||||
|
<view class="action text-bold" style="color:#333333">上传视频(选填)</view> |
||||
|
<view class="action text-sg">支持MP4格式</view> |
||||
|
</view> |
||||
|
<wux-uploader count="1" fileList="{{videoList}}" type="{{'video'}}" bindcustomevent="onVideoChange"></wux-uploader> |
||||
|
</view> |
||||
|
<view class="cu-list menu no-card sm-border margin-top"> |
||||
|
<view id="operation" class="cu-item" bindtap="showPaperPicker"> |
||||
|
<view class="flex flex-justify content cu-item arrow"> |
||||
|
<view class="text-sg" style="min-width:170rpx">废纸品类:</view> |
||||
|
<view class="flex" style="text-align:left"> |
||||
|
<view class="text-sg {{cateName?'text-blue':'input-grey'}}">{{cateName||'请选择废纸品类'}}</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
<text class="cuIcon-right text-gray" wx:if="{{!flag}}" style="font-size:32rpx;padding-top:2rpx"></text> |
||||
|
</view> |
||||
|
<view id="price" class="cu-item" wx:if="{{form.bidType == 1}}"> |
||||
|
<view class="flex flex-justify content cu-item arrow"> |
||||
|
<view class="text-sg" style="min-width:170rpx">商品单价({{kg? '元/KG' : '元/吨'}}):</view> |
||||
|
<input id="unitPrice" maxlength="8" type="{{kg? 'digit' : 'number'}}" class="cate-input" |
||||
|
placeholder-style="color:#aaa" value="{{form.unitPrice||''}}" placeholder="点击输入商品单价" bindinput="bindInput" |
||||
|
bindblur="sumAmount" style="flex: 1"/> |
||||
|
</view> |
||||
|
</view> |
||||
|
<view id="price" class="cu-item" wx:if="{{form.bidType == 2}}"> |
||||
|
<view class="flex flex-justify content cu-item arrow"> |
||||
|
<view class="text-sg" style="min-width:170rpx">起拍单价({{kg? '元/KG' : '元/吨'}}):</view> |
||||
|
<input id="unitPrice" maxlength="8" type="{{kg? 'digit' : 'number'}}" class="cate-input" |
||||
|
placeholder-style="color:#aaa" value="{{form.unitPrice||''}}" placeholder="点击输入起拍单价" bindinput="bindInput" |
||||
|
bindblur="sumAmount" style="flex: 1"/> |
||||
|
</view> |
||||
|
</view> |
||||
|
<view id="weight" class="cu-item"> |
||||
|
<view class="flex flex-justify content cu-item arrow"> |
||||
|
<view class="text-sg" style="min-width:170rpx">库存重量({{ kg? 'KG' : '吨'}}):</view> |
||||
|
<input id="stock" maxlength="8" type="{{kg? 'number' : 'digit'}}" class="cate-input" |
||||
|
placeholder-style="color:#aaa;" value="{{form.stock||''}}" placeholder="点击输入库存重量" bindinput="bindInput" |
||||
|
bindblur="sumAmount" style="flex: 1"/> |
||||
|
</view> |
||||
|
</view> |
||||
|
<view id="price" class="cu-item" wx:if="{{form.bidType == 1}}"> |
||||
|
<view class="flex flex-justify content cu-item arrow"> |
||||
|
<view class="text-sg" style="min-width:170rpx">最少起订重量({{ kg? 'KG' : '吨'}}):</view> |
||||
|
<input id="lowestNum" maxlength="8" type="{{kg? 'number' : 'digit'}}" class="cate-input" |
||||
|
placeholder-style="color:#aaa" value="{{form.lowestNum||''}}" placeholder="点击输入起订重量" bindinput="bindInput" style="flex: 1"/> |
||||
|
</view> |
||||
|
</view> |
||||
|
<view id="biddingInterval" class="cu-item" bindtap="showRadioPicker" wx:if="{{form.bidType == 2}}"> |
||||
|
<view class="flex flex-justify content cu-item arrow"> |
||||
|
<view class="text-sg" style="min-width:170rpx">竞价有效时:</view> |
||||
|
<view class="flex" style="text-align:left"> |
||||
|
<view class="text-sg {{intervalName?'text-blue':'input-grey'}}">{{intervalName||'请选择竞价有效时'}}</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
<text class="cuIcon-right text-gray" wx:if="{{!flag}}" style="font-size:32rpx;padding-top:2rpx"></text> |
||||
|
</view> |
||||
|
<view id="dopantRate" class="cu-item" bindtap="showRadioPicker"> |
||||
|
<view class="flex flex-justify content cu-item arrow"> |
||||
|
<view class="text-sg" style="min-width:170rpx">含杂比例:</view> |
||||
|
<view class="flex" style="text-align:left"> |
||||
|
<view class="text-sg {{dopantName?'text-blue':'input-grey'}}">{{dopantName||'请选择含杂比例'}}</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
<text class="cuIcon-right text-gray" wx:if="{{!flag}}" style="font-size:32rpx;padding-top:2rpx"></text> |
||||
|
</view> |
||||
|
<view id="waterRate" class="cu-item" bindtap="showRadioPicker"> |
||||
|
<view class="flex flex-justify content cu-item arrow"> |
||||
|
<view class="text-sg" style="min-width:170rpx">湿水比例:</view> |
||||
|
<view class="flex" style="text-align:left"> |
||||
|
<view class="text-sg {{waterName?'text-blue':'input-grey'}}">{{waterName||'请选择湿水比例'}}</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
<text class="cuIcon-right text-gray" wx:if="{{!flag}}" style="font-size:32rpx;padding-top:2rpx"></text> |
||||
|
</view> |
||||
|
<view class="cu-item" bindtap="showRegion"> |
||||
|
<view class="flex flex-justify content cu-item arrow"> |
||||
|
<view class="text-sg" style="min-width:170rpx">所在地区:</view> |
||||
|
<view class="flex" style="text-align:left"> |
||||
|
<view class="text-sg {{form.areaStr?'text-blue':'input-grey'}}">{{form.areaStr||'请选择所在地区'}}</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
<text class="cuIcon-right text-gray" wx:if="{{!flag}}" style="font-size:32rpx;padding-top:2rpx"></text> |
||||
|
</view> |
||||
|
<view class="cu-form-group"> |
||||
|
<view class="title">详细地址:</view> |
||||
|
<input id="locDetails" disabled="{{disabled}}" placeholder-style="color:#aaa" placeholder="请输入店铺详细地址" |
||||
|
value="{{form.locDetails}}" bindinput="bindInput" style="flex: 1"></input> |
||||
|
</view> |
||||
|
<view class="cu-bar bg-white margin-top flex flex-justify"> |
||||
|
<view class="action" style="color:#333333">商品描述:</view> |
||||
|
<view class="action" bindtap="templatDescription"> |
||||
|
<text class="cuIcon-sort text-gray" style="font-size:40rpx;margin-right:8rpx;padding-top:2rpx"></text> |
||||
|
<view style="color:#999999;font-size:30rpx;">选择模板</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
<view class="bg-white"> |
||||
|
<view class="textarea" wx:if="{{picking || !focus}}" bindtap="textareaFocus"> |
||||
|
{{form.description.length?form.description:'点击输入商品描述,最多100字'}}</view> |
||||
|
<textarea wx:else id="description" maxlength="100" value="{{form.description}}" bindfocus="InputFocus" |
||||
|
bindblur="InputBlur" class="textarea" cursor-spacing="40" show-confirm-bar="{{false}}" |
||||
|
adjust-position="{{true}}" focus="{{focus}}" bindinput="bindInput" placeholder="点击输入备注,最多100字" |
||||
|
placeholder-style="color:#aaa"></textarea> |
||||
|
</view> |
||||
|
|
||||
|
<view style="height:{{keyboard}}px"></view> |
||||
|
|
||||
|
<!-- <view class="cu-bar bg-white margin-top flex flex-justify" wx:if="{{form.bidType == 1}}"> |
||||
|
<view class="action" style="color:#333333">交易规则:</view> |
||||
|
</view> |
||||
|
<view class="bg-white" wx:if="{{form.bidType == 1}}"> |
||||
|
<view class="textarea"></view> |
||||
|
</view> |
||||
|
<view class="cu-bar bg-white margin-top flex flex-justify" wx:if="{{form.bidType == 2}}"> |
||||
|
<view class="action" style="color:#333333">竞价规则:</view> |
||||
|
</view> |
||||
|
<view class="bg-white" wx:if="{{form.bidType == 2}}"> |
||||
|
<view class="textarea"></view> |
||||
|
</view> --> |
||||
|
|
||||
|
</view> |
||||
|
</scroll-view> |
||||
|
<view style="height:{{136 + safeBottom}}rpx"></view> |
||||
|
<view class="cu-bar bg-white shadow foot flex flex-justify" style="height:{{120 + safeBottom}}rpx;padding: 32rpx 32rpx {{safeBottom + 32}}rpx 32rpx;"> |
||||
|
<view> |
||||
|
<text class="text-gray text-sg">预估总价:</text> |
||||
|
<text class="text-black text-bold" style="font-size: 44rpx">{{goods.formateAmount(sumAmount)}}</text> |
||||
|
<text class="text-gray text-sg" style="margin-left:8rpx">元</text> |
||||
|
</view> |
||||
|
<button class="cu-btn offer-btn" disabled="{{requesting}}" bindtap="submitForm">确认</button> |
||||
|
</view> |
||||
|
|
||||
|
<select-view id="picker-view" bindcustomevent="onPaperChange"></select-view> |
||||
|
<wux-cascader id="wux-cascader" value="{{region}}" options="{{ options }}" bind:close="onRegionChange" /> |
||||
|
<wux-cascader visible="{{ visible }}" controlled value="{{ cateValue }}" options="{{ cateList }}" |
||||
|
bind:close="onCategory" bind:load="onLoadOptions" /> |
||||
@ -0,0 +1,31 @@ |
|||||
|
.margin-top { |
||||
|
margin-top: 18rpx; |
||||
|
} |
||||
|
|
||||
|
.cate-input { |
||||
|
font-size: 30rpx; |
||||
|
text-align: right; |
||||
|
} |
||||
|
|
||||
|
.textarea{ |
||||
|
width:100%; |
||||
|
height:80px; |
||||
|
padding:0px 30rpx; |
||||
|
font-size: 14px; |
||||
|
} |
||||
|
|
||||
|
.bg-blue{ |
||||
|
color: #FFFFFF; |
||||
|
background-color: #008AFF; |
||||
|
} |
||||
|
|
||||
|
.offer-btn { |
||||
|
width: 250rpx; |
||||
|
height: 90rpx; |
||||
|
background: linear-gradient(312deg, rgba(38, 125, 214, 1) 0%, rgba(0, 138, 255, 1) 100%); |
||||
|
box-shadow: 0px 10px 13px -8px rgba(35, 126, 217, 0.53); |
||||
|
border-radius: 23px; |
||||
|
color: white; |
||||
|
font-size: 32rpx; |
||||
|
margin-left: 32rpx; |
||||
|
} |
||||
@ -0,0 +1,316 @@ |
|||||
|
import { getProductInfo } from "../../../../api/ztb" |
||||
|
const util = require('../../../../utils/util') |
||||
|
const math = require('../../../../utils/math') |
||||
|
const event = require('../../../../utils/event') |
||||
|
const app = getApp() |
||||
|
|
||||
|
Page({ |
||||
|
/** |
||||
|
* 页面的初始数据 |
||||
|
*/ |
||||
|
data: { |
||||
|
backStr: '返回', |
||||
|
orderInfo: null, |
||||
|
matchTag: null, |
||||
|
sukList: [], |
||||
|
imgList: [], |
||||
|
form: { |
||||
|
productId: null, |
||||
|
skuId: null, |
||||
|
number: 1, |
||||
|
unitPrice: 0 |
||||
|
}, |
||||
|
amount: null, |
||||
|
safeBottom: false, |
||||
|
imageHeight: 0, |
||||
|
visible: false, |
||||
|
videoUrl: null |
||||
|
}, |
||||
|
/** |
||||
|
* 生命周期函数--监听页面加载 |
||||
|
*/ |
||||
|
onLoad: function (options) { |
||||
|
if (getCurrentPages().length == 1) { |
||||
|
this.setData({ |
||||
|
backStr: '首页' |
||||
|
}) |
||||
|
} |
||||
|
this.setData({ |
||||
|
imageHeight: math.divide(math.times(750, 9), 16), |
||||
|
safeBottom: app.globalData.safeBottom |
||||
|
}) |
||||
|
event.on('EventMessage', this, this.onEvent) |
||||
|
if (options.id) { |
||||
|
wx.showLoading({ |
||||
|
title: '加载中', |
||||
|
mask: true |
||||
|
}) |
||||
|
getProductInfo(options.id).then(result => { |
||||
|
wx.hideLoading() |
||||
|
var vurl = null |
||||
|
var imgList = [] |
||||
|
if (result.data.videoUrl) { |
||||
|
vurl = result.data.videoUrl |
||||
|
imgList = result.data.imgList |
||||
|
imgList.unshift(vurl) |
||||
|
this.videoContext = wx.createVideoContext('video') |
||||
|
} else { |
||||
|
imgList = result.data.imgList |
||||
|
} |
||||
|
this.setData({ |
||||
|
['form.productId']: options.id, |
||||
|
orderInfo: result.data, |
||||
|
videoUrl: vurl, |
||||
|
imgList: imgList |
||||
|
}) |
||||
|
}).catch(err => { |
||||
|
//异常回调
|
||||
|
wx.hideLoading() |
||||
|
util.showToast(err) |
||||
|
}) |
||||
|
} |
||||
|
}, |
||||
|
isVideoUrl: function (url) { |
||||
|
if (url && url.indexOf('.mp4') >= 0) { |
||||
|
return true |
||||
|
} |
||||
|
return false |
||||
|
}, |
||||
|
// 事件处理
|
||||
|
onEvent: function (message) { |
||||
|
console.log('mall>>order>>onEvent', message) |
||||
|
if (message.what == 1) { |
||||
|
|
||||
|
} else if (message.what == 10) { |
||||
|
wx.navigateBack() |
||||
|
} |
||||
|
}, |
||||
|
videoTap: function () { |
||||
|
this.setData({ |
||||
|
visible: true, |
||||
|
}) |
||||
|
if (this.videoContext) { |
||||
|
this.videoContext.play() |
||||
|
} |
||||
|
}, |
||||
|
onClose: function () { |
||||
|
this.setData({ |
||||
|
visible: false, |
||||
|
}) |
||||
|
if (this.videoContext) { |
||||
|
this.videoContext.pause() |
||||
|
} |
||||
|
}, |
||||
|
bindended: function () { |
||||
|
this.videoContext.exitFullScreen() |
||||
|
this.setData({ |
||||
|
visible: false |
||||
|
}) |
||||
|
}, |
||||
|
// 图片查看
|
||||
|
viewImage: function (e) { |
||||
|
if (e.currentTarget.dataset.url.indexOf('.mp4') >= 0) { |
||||
|
return |
||||
|
} |
||||
|
var imgList = [] |
||||
|
for (let index = 0; index < this.data.imgList.length; index++) { |
||||
|
if (this.data.imgList[index].indexOf('.mp4') >= 0) { |
||||
|
continue |
||||
|
} |
||||
|
imgList.push(this.data.imgList[index]) |
||||
|
} |
||||
|
wx.previewImage({ |
||||
|
urls: imgList, |
||||
|
current: e.currentTarget.dataset.url |
||||
|
}); |
||||
|
}, |
||||
|
// 根据
|
||||
|
checkDisableTag: function (sukId, match, element) { |
||||
|
match[sukId] = element.id |
||||
|
for (let index = 0; index < this.data.orderInfo.skuList.length; index++) { |
||||
|
const item = this.data.orderInfo.skuList[index]; |
||||
|
if (this.checkSkuPrice(match, item)) { |
||||
|
delete match[sukId] |
||||
|
return false |
||||
|
} |
||||
|
} |
||||
|
delete match[sukId] |
||||
|
return true |
||||
|
}, |
||||
|
// tag 点击事件
|
||||
|
tagClick: function (e) { |
||||
|
this.data.matchTag = null |
||||
|
var sukId = e.currentTarget.dataset.suk // 对应的是一级列表的Id
|
||||
|
var id = e.currentTarget.dataset.index // 对应的是二级列表的Id,相应是有价格计算的
|
||||
|
//------------------------------sukList-------------------------------------------
|
||||
|
// 检查是否需要跟新,或者修改,跟新sukList;
|
||||
|
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 |
||||
|
}) |
||||
|
} |
||||
|
//------------------------------attributeList-------------------------------------------
|
||||
|
var match = {} |
||||
|
for (let index = 0; index < this.data.sukList.length; index++) { |
||||
|
const element = this.data.sukList[index]; |
||||
|
match[element.skuId] = element.id |
||||
|
} |
||||
|
var attributeList = this.data.orderInfo.attributeList |
||||
|
for (let i = 0; i < attributeList.length; i++) { |
||||
|
for (let k = 0; k < attributeList[i].values.length; k++) { |
||||
|
const element = attributeList[i].values[k]; |
||||
|
// 点击的列判断 对应的是一级列表,肯定是可以点击的
|
||||
|
if (attributeList[i].id == sukId) { |
||||
|
element.select = false |
||||
|
if (element.id == id) { |
||||
|
element.select = true |
||||
|
} |
||||
|
} else { |
||||
|
// 如果其余的规格没有价格的,进行处理;无法点击
|
||||
|
element.disabled = this.checkDisableTag(attributeList[i].id, match, element) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
this.setData({ |
||||
|
['orderInfo.attributeList']: attributeList, |
||||
|
amount: null |
||||
|
}) |
||||
|
//------------------------------matchTag-------------------------------------------
|
||||
|
if (this.data.sukList.length == this.data.orderInfo.attributeList.length) { |
||||
|
this.data.matchTag = {} |
||||
|
for (let index = 0; index < this.data.sukList.length; index++) { |
||||
|
const element = this.data.sukList[index]; |
||||
|
this.data.matchTag[element.skuId] = element.id |
||||
|
} |
||||
|
this.onNumChange(null) |
||||
|
} |
||||
|
}, |
||||
|
// 根据所有选择的规格校验获取价格
|
||||
|
checkSkuPrice: function (tag, element) { |
||||
|
if (!tag) { |
||||
|
return false |
||||
|
} |
||||
|
for (var key in tag) { |
||||
|
if (element.price <= 0 || tag[key] != element[key]) { |
||||
|
return false |
||||
|
} |
||||
|
} |
||||
|
return true |
||||
|
}, |
||||
|
// 数量变化的函数监听
|
||||
|
onNumChange: function (e) { |
||||
|
if (e) { |
||||
|
this.setData({ |
||||
|
['form.number']: e.detail.value |
||||
|
}) |
||||
|
// 如果查询到了价格,进行价格计算
|
||||
|
if (this.data.form.unitPrice) { |
||||
|
this.setData({ |
||||
|
amount: float.accMul(this.data.form.unitPrice, this.data.form.number) |
||||
|
}) |
||||
|
} |
||||
|
} else if (this.data.sukList.length == this.data.orderInfo.attributeList.length) { |
||||
|
// 根据规格,克重,以及其他筛选价格
|
||||
|
for (let index = 0; index < this.data.orderInfo.skuList.length; index++) { |
||||
|
const element = this.data.orderInfo.skuList[index]; |
||||
|
if (this.checkSkuPrice(this.data.matchTag, element)) { |
||||
|
this.data.form.unitPrice = Number(element.price) |
||||
|
this.data.form.monthPrice = Number(element.groupMonthPrice) |
||||
|
this.data.form.stockNumber = Number(element.stockNumber) |
||||
|
// 如果当前的数量大于所选规格的库存数量,那么就设置成库存数量;
|
||||
|
if (this.data.form.number > this.data.form.stockNumber) { |
||||
|
this.data.form.number = Number(element.stockNumber) |
||||
|
} |
||||
|
this.data.form.dividePrice = Number(element.dividePrice) |
||||
|
this.data.form.skuId = element.id |
||||
|
// console.log(element)
|
||||
|
break |
||||
|
} |
||||
|
} |
||||
|
// 如果查询到了价格,进行价格计算
|
||||
|
if (this.data.form.unitPrice) { |
||||
|
this.setData({ |
||||
|
['form.number']: this.data.form.number, |
||||
|
['form.unitPrice']: this.data.form.unitPrice, |
||||
|
['form.stockNumber']: this.data.form.stockNumber, |
||||
|
amount: float.accMul(this.data.form.unitPrice, this.data.form.number) |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
// 进入支付流程
|
||||
|
offerProject: function (e) { |
||||
|
var attributeList = this.data.orderInfo.attributeList |
||||
|
for (let i = 0; i < attributeList.length; i++) { |
||||
|
var toast = '请选择' + attributeList[i].name |
||||
|
for (let k = 0; k < attributeList[i].values.length; k++) { |
||||
|
const element = attributeList[i].values[k]; |
||||
|
if (element.select) { |
||||
|
toast = '' |
||||
|
break |
||||
|
} |
||||
|
} |
||||
|
if (!util.isEmpty(toast)) { |
||||
|
util.showToast(toast) |
||||
|
return |
||||
|
} |
||||
|
} |
||||
|
if (this.data.form.number <= 0) { |
||||
|
util.showToast('请输入购买数量,必选大于0') |
||||
|
return |
||||
|
} |
||||
|
if (this.data.form.stockNumber <= 0) { |
||||
|
util.showToast('暂无库存,请选择其他规格类型') |
||||
|
return |
||||
|
} |
||||
|
this.data.form.summary = this.data.orderInfo.summary |
||||
|
this.data.form.sellMode = this.data.orderInfo.sellMode |
||||
|
this.data.form.name = this.data.orderInfo.name |
||||
|
this.data.form.outline = this.data.orderInfo.outline |
||||
|
this.data.form.litimgUrl = this.data.orderInfo.litimgUrl |
||||
|
this.data.form.unit = this.data.orderInfo.unit |
||||
|
wx.navigateTo({ |
||||
|
url: '/pages/mall/order-offer/index?json=' + JSON.stringify(this.data.form) |
||||
|
}) |
||||
|
}, |
||||
|
onShareAppMessage: function () { |
||||
|
return { |
||||
|
title: this.data.orderInfo.name, |
||||
|
path: '/pages/mall/order-info/index?id=' + this.data.orderInfo.id, |
||||
|
imageUrl: this.data.orderInfo.litimgUrl, |
||||
|
success: function (res) {} |
||||
|
} |
||||
|
}, |
||||
|
// 分享至朋友圈
|
||||
|
onShareTimeline(res) { |
||||
|
return { |
||||
|
title: this.data.orderInfo.name, |
||||
|
path: '/pages/mall/order-info/index?id=' + this.data.orderInfo.id, |
||||
|
imageUrl: this.data.orderInfo.litimgUrl, |
||||
|
success: function (res) {} |
||||
|
} |
||||
|
}, |
||||
|
// event的unregister
|
||||
|
onUnload: function () { |
||||
|
event.remove('EventMessage', this) |
||||
|
if (getCurrentPages().length == 1) { |
||||
|
this.toHome() |
||||
|
} |
||||
|
}, |
||||
|
// 返回到主页
|
||||
|
toHome() { |
||||
|
wx.reLaunch({ |
||||
|
url: '/pages/mall/shops/index', |
||||
|
}) |
||||
|
} |
||||
|
}) |
||||
@ -0,0 +1,7 @@ |
|||||
|
{ |
||||
|
"usingComponents": { |
||||
|
"wux-button": "/components/button/index", |
||||
|
"wux-input-number": "/components/input-number/index", |
||||
|
"wux-landscape": "/components/landscape/index" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,73 @@ |
|||||
|
<wxs module="goods" src="../../goods/goods.wxs"></wxs> |
||||
|
<cu-custom bgColor="bg-white" isBack="{{true}}"> |
||||
|
<view slot="content" style="color:black;font-size:36rpx">商品详情</view> |
||||
|
</cu-custom> |
||||
|
|
||||
|
<view wx:if="{{orderInfo}}"> |
||||
|
<swiper class="screen-swiper square-dot" style="min-height:{{imageHeight}}rpx" indicator-dots="true" indicator-color="#FFFFFF" indicator-active-color="#008AFF"> |
||||
|
<swiper-item wx:for="{{imgList}}" wx:key="index"> |
||||
|
<view wx:if="{{goods.isVideoUrl(item)}}"> |
||||
|
<view class="video-cnt"> |
||||
|
<video src="{{item}}" style="width:100%;min-height:{{imageHeight}}rpx" show-center-play-btn="{{false}}" controls="{{false}}"/> |
||||
|
</view> |
||||
|
<text class="play-btn cuIcon-video text-white" style="font-size:80rpx" catchtap="videoTap" wx:if="{{!visible}}"></text> |
||||
|
</view> |
||||
|
<view wx:else bindtap="viewImage" style="width:100%;height:100%" data-url="{{item}}"> |
||||
|
<image src="{{item}}" mode="aspectFill"></image> |
||||
|
</view> |
||||
|
</swiper-item> |
||||
|
</swiper> |
||||
|
<view class="bg-white flex flex-justify" style="padding:24rpx 32rpx"> |
||||
|
<view class="flex flex-center"> |
||||
|
<view class="detail-price">¥{{form.unitPrice || orderInfo.price}}</view> |
||||
|
<view class="text-gray" style="font-size:24rpx;margin-left:48rpx">库存:{{form.stockNumber >= 0 ? form.stockNumber : orderInfo.stockNumber}}{{orderInfo.unit}}</view> |
||||
|
</view> |
||||
|
<view class="text-gray" style="font-size:24rpx">{{orderInfo.viewNum}} 浏览</view> |
||||
|
</view> |
||||
|
|
||||
|
<view class="bg-white text-name" style="padding:0rpx 32rpx">{{orderInfo.name}}</view> |
||||
|
|
||||
|
<view class="bg-white"> |
||||
|
<view style="height:1px;width:100%;background-color:#F3F3F3;margin-left:32rpx"></view> |
||||
|
</view> |
||||
|
<view class="bg-white flex flex-justify" style="height:100rpx;;padding: 0rpx 32rpx"> |
||||
|
<view class="text-gray" style="font-size:28rpx">购买数量</view> |
||||
|
<wux-input-number value="{{form.number}}" controlled="{{true}}" disabled="{{false}}" color="stable" min="{{goods.minNumber(orderInfo, 1)}}" max="{{form.stockNumber||orderInfo.stockNumber}}" bind:change="onNumChange" /> |
||||
|
</view> |
||||
|
|
||||
|
<view class="bg-white" style="padding:32rpx;margin-top:32rpx"> |
||||
|
<view class="text-black" style="font-size:32rpx">商品描述</view> |
||||
|
<view class="text-gray" style="font-size:28rpx;margin-top:32rpx">{{orderInfo.description}}</view> |
||||
|
</view> |
||||
|
<view class="bg-white"> |
||||
|
<view style="height:1px;width:100%;background-color:#F3F3F3;margin-left:32rpx"></view> |
||||
|
</view> |
||||
|
|
||||
|
<view class="booking-tool" style="bottom:{{280 + safeBottom}}rpx"> |
||||
|
<view class="roder-add flex flex-center"> |
||||
|
<button open-type="share" style="background-color: #fff;border-radius: 0;padding-left: 0px;padding-right: 0px;height:32px"> |
||||
|
<image style="width:40rpx;height:40rpx;margin-bottom:3px" src="/assets/image/icon_share.png"></image> |
||||
|
</button> |
||||
|
</view> |
||||
|
</view> |
||||
|
|
||||
|
<view style="height:{{136 + safeBottom}}rpx;"></view> |
||||
|
<view class="cu-bar bg-white shadow foot flex flex-justify" style="height:{{120 + safeBottom}}rpx;padding:32rpx 32rpx {{safeBottom}}rpx 32rpx"> |
||||
|
<button class="flex flex-column" open-type="contact" style="background-color: #fff;border-radius: 0;margin-left:-20rpx"> |
||||
|
<image style="width:60rpx;height:60rpx" src="/assets/image/icon_wechat.svg"></image> |
||||
|
<view style="font-size:28rpx;line-height: 24rpx">客服</view> |
||||
|
</button> |
||||
|
<view class="flex align-end"> |
||||
|
<view wx:if="{{amount}}"> |
||||
|
<text class="text-black" style="font-size:32rpx">合计:</text> |
||||
|
<text class="text-blue" style="font-size:32rpx">¥{{amount}}</text> |
||||
|
</view> |
||||
|
<button wx:if="{{token}}" class="cu-btn offer-btn" bindtap="offerProject">立即购买</button> |
||||
|
<button wx:else class="cu-btn offer-btn" open-type="getPhoneNumber" bindgetphonenumber="onGotPhoneNumber">立即购买</button> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
|
||||
|
<wux-landscape visible="{{ visible }}" bind:close="onClose"> |
||||
|
<video id="video" src="{{videoUrl}}" style="width:750rpx;min-height:{{imageHeight}}rpx" show-center-play-btn="{{false}}" bindended="bindended" /> |
||||
|
</wux-landscape> |
||||
@ -0,0 +1,79 @@ |
|||||
|
.margin-top { |
||||
|
margin-top: 18rpx; |
||||
|
} |
||||
|
|
||||
|
.detail-price { |
||||
|
font-size: 32rpx; |
||||
|
font-family: DINAlternate-Bold, DINAlternate; |
||||
|
font-weight: bold; |
||||
|
color: rgba(255, 66, 43, 1); |
||||
|
line-height: 20px; |
||||
|
} |
||||
|
|
||||
|
.text-name { |
||||
|
font-size: 32rpx; |
||||
|
font-family: PingFang-SC-Medium, PingFang-SC; |
||||
|
font-weight: 500; |
||||
|
color: rgba(51, 51, 51, 1); |
||||
|
line-height: 22px; |
||||
|
} |
||||
|
|
||||
|
.offer-btn { |
||||
|
width: 150px; |
||||
|
height: 45px; |
||||
|
background: linear-gradient(312deg, rgba(38, 125, 214, 1) 0%, rgba(0, 138, 255, 1) 100%); |
||||
|
box-shadow: 0px 10px 13px -8px rgba(35, 126, 217, 0.53); |
||||
|
border-radius: 23px; |
||||
|
color: white; |
||||
|
font-size: 32rpx; |
||||
|
margin-left: 32rpx; |
||||
|
} |
||||
|
|
||||
|
button::after { |
||||
|
border: none; |
||||
|
} |
||||
|
|
||||
|
.booking-tool { |
||||
|
width: calc(100% - 20px); |
||||
|
background-color: #fff; |
||||
|
position: fixed; |
||||
|
bottom: 150px; |
||||
|
left: 25px; |
||||
|
} |
||||
|
|
||||
|
.roder-add { |
||||
|
display: flex; |
||||
|
justify-content: center; |
||||
|
align-items: center; |
||||
|
width: 40px; |
||||
|
height: 40px; |
||||
|
background-color: #fff; |
||||
|
border-radius: 20px; |
||||
|
position: absolute; |
||||
|
top: 24px; |
||||
|
right: 24px; |
||||
|
box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16); |
||||
|
} |
||||
|
|
||||
|
.swiper-cnt { |
||||
|
display: flex; |
||||
|
flex-direction: column; |
||||
|
width: 100%; |
||||
|
position: relative; |
||||
|
} |
||||
|
|
||||
|
.video-cnt { |
||||
|
position: absolute; |
||||
|
top: 0; |
||||
|
left: 0; |
||||
|
z-index: -1 !important; |
||||
|
width: 100%; |
||||
|
height: 100%; |
||||
|
} |
||||
|
|
||||
|
.play-btn { |
||||
|
position: absolute; |
||||
|
top: 150rpx; |
||||
|
left: 342rpx; |
||||
|
z-index: 100; |
||||
|
} |
||||
@ -0,0 +1,141 @@ |
|||||
|
import { paperCategoryList, getMiniProxyList } from "../../../../api/ztb" |
||||
|
const app = getApp() |
||||
|
const statusList = [1, 2] |
||||
|
|
||||
|
Component({ |
||||
|
options: { |
||||
|
addGlobalClass: true, |
||||
|
multipleSlots: true |
||||
|
}, |
||||
|
/** |
||||
|
* 页面的初始数据 |
||||
|
*/ |
||||
|
data: { |
||||
|
height: app.globalData.fragmentHeight - 210, |
||||
|
CustomBar: app.globalData.CustomBar, |
||||
|
kg: app.globalData.kg, |
||||
|
loading: true, |
||||
|
requesting: false, |
||||
|
finished: false, |
||||
|
cateList: [], |
||||
|
cateScroll: false, |
||||
|
tabiList: [], |
||||
|
pageIndex: 0, |
||||
|
top: 0, |
||||
|
orderList: [], |
||||
|
form: { |
||||
|
firstCategoryId: '', |
||||
|
bidType: statusList[0], |
||||
|
pageNum: 1, |
||||
|
pageSize:15 |
||||
|
}, |
||||
|
}, |
||||
|
methods: { |
||||
|
onRestart: function(){ |
||||
|
if (!this.data.firstShow) { |
||||
|
this.setData({ height: app.globalData.fragmentHeight - 210, kg: app.globalData.kg }) |
||||
|
this.fetchCateList() |
||||
|
this.fetchGoodsList() |
||||
|
} |
||||
|
this.data.firstShow = true |
||||
|
}, |
||||
|
fetchCateList: function(){ |
||||
|
paperCategoryList({ type: 1 }).then(result => { |
||||
|
var tabList = ['全部'] |
||||
|
var size = 0 |
||||
|
for (let index = 0; index < result.data.length; index++) { |
||||
|
tabList.push(result.data[index].name) |
||||
|
size += result.data[index].name.length |
||||
|
} |
||||
|
this.data.cateList = result.data |
||||
|
this.setData({ tabiList: tabList, cateScroll: size > 14 }) |
||||
|
}) |
||||
|
}, |
||||
|
onCategoryChange: function ({detail}) { |
||||
|
if(this.data.pageIndex == Number(detail.index)){ |
||||
|
return |
||||
|
} |
||||
|
this.data.pageIndex = Number(detail.index) |
||||
|
if(this.data.pageIndex == 0){ |
||||
|
this.data.form.firstCategoryId = '' |
||||
|
} else { |
||||
|
this.data.form.firstCategoryId = this.data.cateList[this.data.pageIndex - 1].id |
||||
|
} |
||||
|
this.onRefreshList() |
||||
|
}, |
||||
|
onTabChange: function (e) { |
||||
|
if (this.data.form.bidType == Number(e.currentTarget.dataset.index)) { |
||||
|
return |
||||
|
} |
||||
|
var tabIndex = Number(e.currentTarget.dataset.index) |
||||
|
// this.data.form.bidType = statusList[this.data.tabIndex]
|
||||
|
this.data.form.firstCategoryId = '' |
||||
|
this.setData({ pageIndex: 0, ['form.bidType']: tabIndex }) |
||||
|
this.onRefreshList() |
||||
|
}, |
||||
|
// 下拉刷新...
|
||||
|
onRefreshList: function () { |
||||
|
if (this.data.requesting) { |
||||
|
return |
||||
|
} |
||||
|
this.setData({ |
||||
|
orderList: [], |
||||
|
['form.pageNum']: 1, |
||||
|
loading: true, |
||||
|
finished: false |
||||
|
}) |
||||
|
this.fetchGoodsList() |
||||
|
}, |
||||
|
// 获取特价列表
|
||||
|
fetchGoodsList: function () { |
||||
|
if (this.data.requesting || this.data.finished) { |
||||
|
return |
||||
|
} |
||||
|
if (this.data.loading) { |
||||
|
this.data.requesting = true |
||||
|
} else { |
||||
|
this.setData({ requesting: true }) |
||||
|
} |
||||
|
getMiniProxyList(this.data.form).then(result => { |
||||
|
if (result.data.records.length) { |
||||
|
var respList = result.data.records |
||||
|
let nowList = `orderList[${this.data.orderList.length}]` |
||||
|
var num = result.data.current |
||||
|
var finished = result.data.current >= result.data.pages |
||||
|
if(this.data.form.pageNum == 1){ |
||||
|
this.setData({ |
||||
|
[nowList]: respList, |
||||
|
total: result.data.total, |
||||
|
['form.pageNum']: (num + 1), |
||||
|
top: 0, |
||||
|
finished, |
||||
|
requesting: false, |
||||
|
loading: false |
||||
|
}) |
||||
|
} else { |
||||
|
this.setData({ |
||||
|
[nowList]: respList, |
||||
|
total: result.data.total, |
||||
|
['form.pageNum']: (num + 1), |
||||
|
finished, |
||||
|
requesting: false, |
||||
|
loading: false |
||||
|
}) |
||||
|
} |
||||
|
} else { |
||||
|
this.setData({ finished: true, requesting: false, loading: false }) |
||||
|
} |
||||
|
}).catch(err => { |
||||
|
this.setData({ requesting: false, finished: true, loading: false }) |
||||
|
}) |
||||
|
}, |
||||
|
lookItem: function (e) { |
||||
|
var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] |
||||
|
wx.navigateTo({ url: '/pages/mall/detail/index?id=' + item.id }) |
||||
|
}, |
||||
|
offerGood: function(e){ |
||||
|
var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] |
||||
|
wx.navigateTo({ url: '/pages/mall/detail/index?id=' + item.id }) |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
@ -0,0 +1,15 @@ |
|||||
|
{ |
||||
|
"usingComponents": { |
||||
|
"wux-skeleton": "/components/skeleton/index", |
||||
|
"wux-skeleton-avatar": "/components/skeleton-avatar/index", |
||||
|
"wux-skeleton-paragraph": "/components/skeleton-paragraph/index", |
||||
|
"wux-row": "/components/row/index", |
||||
|
"wux-col": "/components/col/index", |
||||
|
"refresh-view": "/components/refresher/index", |
||||
|
"wux-button": "/components/button/index", |
||||
|
"wux-tabi": "/components/tabi/index", |
||||
|
"wux-image": "/components/image/index", |
||||
|
"wux-divider": "/components/divider/index", |
||||
|
"product-item": "/pages/goods/product-item/index" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,53 @@ |
|||||
|
<wxs module="formate" src="../../../../pages/formate.wxs"></wxs> |
||||
|
|
||||
|
<view class="flex bg-white" style="height:120rpx;padding:12rpx 12rpx 0rpx 12rpx;border-bottom: 2rpx solid #eee"> |
||||
|
<view data-index="1" class="flex flex-center flex-column" style="flex:1;" bindtap="onTabChange"> |
||||
|
<view class="text-bold" style="font-size:36rpx;color:{{form.bidType == 1 ? '#008AFF' : '#333'}}">一口价专区</view> |
||||
|
<view style="font-size:24rpx;color:{{form.bidType == 1 ? '#008AFF' : '#999'}};margin-top:8rpx">担保交易 支持退货</view> |
||||
|
<view style="width:80rpx;height:6rpx;background-color:#008AFF;margin-top:12rpx;visibility:{{form.bidType == 1 ? 'visible' : 'hidden'}}"></view> |
||||
|
</view> |
||||
|
<view data-index="2" class="flex flex-center flex-column" style="flex:1;" bindtap="onTabChange"> |
||||
|
<view class="text-bold" style="font-size:36rpx;color:{{form.bidType == 2 ? '#008AFF' : '#333'}}">特价专区</view> |
||||
|
<view style="font-size:24rpx;color:{{form.bidType == 2 ? '#008AFF' : '#999'}};margin-top:8rpx">稀有资源 限时特价</view> |
||||
|
<view style="width:80rpx;height:6rpx;background-color:#008AFF;margin-top:12rpx;visibility:{{form.bidType == 2 ? 'visible' : 'hidden'}}"></view> |
||||
|
</view> |
||||
|
</view> |
||||
|
<view class="bg-white" style="height:90rpx;border-bottom: 2rpx solid #eee"> |
||||
|
<wux-tabi scroll="{{cateScroll}}" tab-data="{{tabiList}}" tab-index="{{pageIndex}}" bind:change="onCategoryChange"></wux-tabi> |
||||
|
</view> |
||||
|
|
||||
|
<refresh-view bind:refresh="onRefreshList" height="{{height}}" triggered="{{requesting}}" scrollTop="{{top}}" bind:scrolltolower="fetchGoodsList"> |
||||
|
<view class="bg-white list-empty" style="height:{{ height }}rpx" wx:if="{{!orderList.length}}"> |
||||
|
<view class="load-spinner text-gray" style="margin-bottom:24px" wx:if="{{loading}}" /> |
||||
|
<image class="img-empty" src="/assets/image/list_empty.png" wx:else></image> |
||||
|
<view class="text-empty"> |
||||
|
<text wx:if="{{loading}}">正在加载</text> |
||||
|
<view wx:else> |
||||
|
<view wx:if="{{form.bidType == 2}}"> |
||||
|
<view>特价商品发布中,</view> |
||||
|
<view>先去一口价专区逛逛吧。</view> |
||||
|
</view> |
||||
|
<view wx:else>暂无数据</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
<view wx:else> |
||||
|
<view wx:for-item="pageItem" wx:for-index="pageIndex" wx:for="{{orderList}}" wx:key="pageIndex"> |
||||
|
<view wx:for="{{pageItem}}" wx:key="index"> |
||||
|
<view class="bg-white" style="padding: 0rpx 32rpx" wx:if="{{pageIndex != 0 || index != 0 }}"> |
||||
|
<wux-divider show-text="{{ false }}"></wux-divider> |
||||
|
</view> |
||||
|
<product-item item="{{item}}"></product-item> |
||||
|
</view> |
||||
|
</view> |
||||
|
<!--加载更多的UI--> |
||||
|
<view wx:if="{{form.pageNum > 1}}" style="padding:20rpx"> |
||||
|
<wux-divider> |
||||
|
<view class="loadmore"> |
||||
|
<text class="icon--refresher" wx:if="{{!finished}}"></text> |
||||
|
<text class="text-sm" style="margin-left:8rpx">{{finished?'到底啦~':'加载中...'}}</text> |
||||
|
</view> |
||||
|
</wux-divider> |
||||
|
</view> |
||||
|
</view> |
||||
|
</refresh-view> |
||||
@ -0,0 +1,133 @@ |
|||||
|
function isEmpty(val) { |
||||
|
return typeof val === 'undefined' || val === '' || val === null |
||||
|
} |
||||
|
|
||||
|
function orderStatus(status) { |
||||
|
if (status == 2) { |
||||
|
return '待确认' |
||||
|
} else if (status == 3 || status == 30) { |
||||
|
return '待审核' |
||||
|
} else if (status == 23 || status == 31) { |
||||
|
return '待审核' |
||||
|
} else if (status == 4) { |
||||
|
return '已完成' |
||||
|
} else if (status == 5) { |
||||
|
return '已取消' |
||||
|
} else if (status == 6) { |
||||
|
return '不通过' |
||||
|
} |
||||
|
return '' |
||||
|
} |
||||
|
|
||||
|
|
||||
|
function numberFormat(value, fix) { |
||||
|
if (value) { |
||||
|
return value.toFixed(fix) |
||||
|
} |
||||
|
return '' |
||||
|
} |
||||
|
|
||||
|
function orderOperated(status) { |
||||
|
return status in [2, 3, 4] |
||||
|
} |
||||
|
|
||||
|
function settleOrder(orderInfo, type) { |
||||
|
if (type == 1) { |
||||
|
if (parseFloat(orderInfo.settleWeight) > 0) { |
||||
|
return numberFormat(orderInfo.settleWeight, 3) |
||||
|
} |
||||
|
if (parseFloat(orderInfo.allSettleWeight) > 0) { |
||||
|
return numberFormat(orderInfo.allSettleWeight, 3) |
||||
|
} |
||||
|
} else if (type == 2) { |
||||
|
if (parseFloat(orderInfo.settlePrice) > 0) { |
||||
|
return numberFormat(orderInfo.settlePrice, 2) |
||||
|
} |
||||
|
if (!isEmpty(orderInfo.allTotalPrice) && parseFloat(orderInfo.allTotalPrice) > 0) { |
||||
|
return numberFormat(orderInfo.allTotalPrice, 2) |
||||
|
} |
||||
|
} |
||||
|
return '' |
||||
|
} |
||||
|
|
||||
|
function formatePrice(price) { |
||||
|
return Number(parseFloat(price) / 100).toFixed(2) |
||||
|
} |
||||
|
|
||||
|
function formateWeight(weight, kg) { |
||||
|
if (weight || weight == 0) { |
||||
|
if (kg) { |
||||
|
return (parseFloat(weight)).toFixed(1) |
||||
|
} else { |
||||
|
return (parseFloat(weight) / 1000).toFixed(3) |
||||
|
} |
||||
|
} |
||||
|
return '' |
||||
|
} |
||||
|
|
||||
|
function formateAmount(price) { |
||||
|
return Number(parseFloat(price)).toFixed(2) |
||||
|
} |
||||
|
|
||||
|
function formateDate(datetime) { |
||||
|
if (isEmpty(datetime)) { |
||||
|
return '' |
||||
|
} |
||||
|
var date = getDate(datetime.trim()) |
||||
|
var today = getDate() |
||||
|
var dayCode = 24 * 60 * 60 * 1000 |
||||
|
var week = '' |
||||
|
if (date.getTime() === today.getTime()) { |
||||
|
week = '(今天)' |
||||
|
} else if (date.getTime() === today.getTime() + dayCode) { |
||||
|
week = '(明天)' |
||||
|
} else if (date.getTime() === today.getTime() - dayCode) { |
||||
|
week = '(昨天)' |
||||
|
} else if (date.getTime() === today.getTime() + dayCode * 2) { |
||||
|
week = '(后天)' |
||||
|
} else { |
||||
|
week = ['(周日)', '(周一)', '(周二)', '(周三)', '(周四)', '(周五)', '(周六)'][date.getDay()] |
||||
|
} |
||||
|
if (isEmpty(week)) { |
||||
|
week = '' |
||||
|
} |
||||
|
return datetime + week |
||||
|
} |
||||
|
|
||||
|
function formateText(text, length) { |
||||
|
if (!text) { |
||||
|
return '' |
||||
|
} |
||||
|
if (text.length <= length) { |
||||
|
return text |
||||
|
} |
||||
|
return text.substring(0, length) + '...' |
||||
|
} |
||||
|
|
||||
|
function isVideoUrl(url) { |
||||
|
if (url && url.indexOf('.mp4') >= 0) { |
||||
|
return true |
||||
|
} |
||||
|
return false |
||||
|
} |
||||
|
|
||||
|
function minNumber(order, num) { |
||||
|
if (order && parseInt(order.minBuyNum) > 0) { |
||||
|
return Number(order.minBuyNum) |
||||
|
} |
||||
|
return num |
||||
|
} |
||||
|
|
||||
|
module.exports = { |
||||
|
orderStatus: orderStatus, |
||||
|
numberFormat: numberFormat, |
||||
|
orderOperated: orderOperated, |
||||
|
settleOrder: settleOrder, |
||||
|
formatePrice: formatePrice, |
||||
|
formateWeight: formateWeight, |
||||
|
formateDate: formateDate, |
||||
|
formateText: formateText, |
||||
|
isVideoUrl: isVideoUrl, |
||||
|
minNumber: minNumber, |
||||
|
formateAmount: formateAmount |
||||
|
} |
||||
@ -0,0 +1,238 @@ |
|||||
|
import { paperCategoryList, getGoodProductList, statusProductInfo, deleteProduct } from "../../../../api/ztb" |
||||
|
const util = require('../../../../utils/util') |
||||
|
const event = require('../../../../utils/event') |
||||
|
const app = getApp() |
||||
|
const statusList = [1, 2] |
||||
|
|
||||
|
Page({ |
||||
|
|
||||
|
/** |
||||
|
* 页面的初始数据 |
||||
|
*/ |
||||
|
data: { |
||||
|
height: app.globalData.fragmentHeight, |
||||
|
kg: app.globalData.kg, |
||||
|
loading: true, |
||||
|
requesting: false, |
||||
|
finished: false, |
||||
|
tabList: ['一口价商品', '特价商品'], |
||||
|
tabIndex: 0, |
||||
|
tabScroll: false, |
||||
|
cateList: [], |
||||
|
cateScroll: false, |
||||
|
tabiList: [], |
||||
|
pageIndex: 0, |
||||
|
top: 0, |
||||
|
orderList: [], |
||||
|
form: { |
||||
|
firstCategoryId: '', |
||||
|
bidType: 1, |
||||
|
pageNum: 1, |
||||
|
pageSize:15 |
||||
|
} |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 生命周期函数--监听页面加载 |
||||
|
*/ |
||||
|
onLoad: function (options) { |
||||
|
this.setData({ |
||||
|
height: app.globalData.fragmentHeight - 180, |
||||
|
kg: app.globalData.kg, |
||||
|
CustomBar: app.globalData.CustomBar |
||||
|
}) |
||||
|
event.on('EventMessage', this, this.onEvent) |
||||
|
this.wuxDialog = this.wuxDialog || this.selectComponent('#wux-dialog') |
||||
|
this.fetchCateList() |
||||
|
this.fetchGoodsList() |
||||
|
}, |
||||
|
onEvent: function (message) { |
||||
|
console.log('goods>>index>>onEvent', message) |
||||
|
if (message.what == 102) { |
||||
|
this.onRefreshList() |
||||
|
} |
||||
|
}, |
||||
|
onRefreshList: function () { |
||||
|
if (this.data.requesting) { |
||||
|
return |
||||
|
} |
||||
|
this.setData({ |
||||
|
orderList: [], |
||||
|
['form.firstCategoryId']: this.data.form.firstCategoryId, |
||||
|
['form.bidType']: this.data.form.bidType, |
||||
|
['form.pageNum']: 1, |
||||
|
loading: true, |
||||
|
finished: false |
||||
|
}) |
||||
|
this.fetchGoodsList() |
||||
|
}, |
||||
|
fetchCateList: function(){ |
||||
|
paperCategoryList({ type: 1 }).then(result => { |
||||
|
//成功回调
|
||||
|
var tabList = ['全部'] |
||||
|
var size = 0 |
||||
|
for (let index = 0; index < result.data.length; index++) { |
||||
|
tabList.push(result.data[index].name) |
||||
|
size += result.data[index].name.length |
||||
|
} |
||||
|
this.data.cateList = result.data |
||||
|
this.setData({ tabiList: tabList, cateScroll: size > 14 }) |
||||
|
}) |
||||
|
}, |
||||
|
onCategoryChange: function ({detail}) { |
||||
|
if(this.data.pageIndex == Number(detail.index)){ |
||||
|
return |
||||
|
} |
||||
|
this.data.pageIndex = Number(detail.index) |
||||
|
if(this.data.pageIndex == 0){ |
||||
|
this.data.form.firstCategoryId = '' |
||||
|
} else { |
||||
|
this.data.form.firstCategoryId = this.data.cateList[this.data.pageIndex - 1].id |
||||
|
} |
||||
|
this.onRefreshList() |
||||
|
}, |
||||
|
fetchGoodsList: function () { |
||||
|
if (this.data.requesting || this.data.finished) { |
||||
|
return |
||||
|
} |
||||
|
if (this.data.loading) { |
||||
|
this.data.requesting = true |
||||
|
} else { |
||||
|
this.setData({ requesting: true }) |
||||
|
} |
||||
|
getGoodProductList(this.data.form).then(result => { |
||||
|
if (result.data.records.length) { |
||||
|
var respList = result.data.records |
||||
|
let nowList = `orderList[${this.data.orderList.length}]` |
||||
|
var num = this.data.form.pageNum |
||||
|
var finished = this.data.form.pageNum >= result.data.pages |
||||
|
if(this.data.form.pageNum == 1){ |
||||
|
this.setData({ |
||||
|
[nowList]: respList, |
||||
|
total: result.data.total, |
||||
|
['form.pageNum']: (num + 1), |
||||
|
top: 0, |
||||
|
finished, |
||||
|
requesting: false, |
||||
|
loading: false |
||||
|
}) |
||||
|
} else { |
||||
|
this.setData({ |
||||
|
[nowList]: respList, |
||||
|
total: result.data.total, |
||||
|
['form.pageNum']: (num + 1), |
||||
|
finished, |
||||
|
requesting: false, |
||||
|
loading: false |
||||
|
}) |
||||
|
} |
||||
|
} else { |
||||
|
this.setData({ |
||||
|
finished: true, |
||||
|
requesting: false, |
||||
|
loading: false |
||||
|
}) |
||||
|
} |
||||
|
}).catch(err => { |
||||
|
//异常回调
|
||||
|
this.setData({ |
||||
|
requesting: false, |
||||
|
loading: false |
||||
|
}) |
||||
|
util.showToast(err) |
||||
|
}) |
||||
|
}, |
||||
|
lookItem: function (e) { |
||||
|
var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] |
||||
|
// wx.navigateTo({
|
||||
|
// url: '/pages/goods/detail/index?id=' + item.id
|
||||
|
// })
|
||||
|
}, |
||||
|
editItem: function (e) { |
||||
|
var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] |
||||
|
wx.navigateTo({ url: '/pages/goods/create/index?id=' + item.id }) |
||||
|
}, |
||||
|
shelvesItem: function (e) { |
||||
|
var page = e.currentTarget.dataset.page |
||||
|
var index = e.currentTarget.dataset.index |
||||
|
var item = this.data.orderList[page][index] |
||||
|
var that = this |
||||
|
if(item.status == 1){ |
||||
|
this.wuxDialog.open({ |
||||
|
resetOnClose: true, |
||||
|
title: '温馨提示', |
||||
|
content: '确定下架该商品?', |
||||
|
buttons: [{ |
||||
|
text: '取消' |
||||
|
}, { |
||||
|
text: '确定', |
||||
|
type: 'primary', |
||||
|
onTap(e) { |
||||
|
that.statusItem(item, page, index, 2) |
||||
|
} |
||||
|
}] |
||||
|
}) |
||||
|
} else { |
||||
|
that.statusItem(item, page, index, 1) |
||||
|
} |
||||
|
}, |
||||
|
statusItem: function(item, page, index, status){ |
||||
|
wx.showLoading({ title: '处理中', mask: true }) |
||||
|
statusProductInfo({productId: item.id, status}).then(result => { |
||||
|
this.setData({ ['orderList[' + page + '][' + index + '].status']: status }) |
||||
|
wx.hideLoading() |
||||
|
if(status == 2){ |
||||
|
util.showToast('商品下架成功!') |
||||
|
} else { |
||||
|
util.showToast('商品上架成功!') |
||||
|
} |
||||
|
}).catch(err => { |
||||
|
//异常回调
|
||||
|
wx.hideLoading() |
||||
|
util.showToast(err) |
||||
|
}) |
||||
|
}, |
||||
|
removeItem: function (e) { |
||||
|
var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] |
||||
|
var that = this |
||||
|
this.wuxDialog.open({ |
||||
|
resetOnClose: true, |
||||
|
title: '温馨提示', |
||||
|
content: '确定删除该商品?', |
||||
|
buttons: [{ |
||||
|
text: '取消' |
||||
|
}, { |
||||
|
text: '确定', |
||||
|
type: 'primary', |
||||
|
onTap(e) { |
||||
|
that.deleteItem(item) |
||||
|
} |
||||
|
}] |
||||
|
}) |
||||
|
}, |
||||
|
deleteItem: function(item){ |
||||
|
wx.showLoading({ title: '处理中', mask: true }) |
||||
|
deleteProduct({productId: item.id}).then(result => { |
||||
|
wx.hideLoading() |
||||
|
this.onRefreshList() |
||||
|
util.showToast('商品删除成功!') |
||||
|
}).catch(err => { |
||||
|
//异常回调
|
||||
|
wx.hideLoading() |
||||
|
util.showToast(err) |
||||
|
}) |
||||
|
}, |
||||
|
onTabChange: function ({detail}) { |
||||
|
if (this.data.tabIndex == detail.index) { |
||||
|
return |
||||
|
} |
||||
|
this.data.tabIndex = detail.index |
||||
|
this.data.form.bidType = statusList[this.data.tabIndex] |
||||
|
this.data.form.firstCategoryId = '' |
||||
|
this.setData({ pageIndex: 0, ['form.bidType']: statusList[this.data.tabIndex] }) |
||||
|
this.onRefreshList() |
||||
|
}, |
||||
|
onUnload: function(){ |
||||
|
event.remove('EventMessage', this) |
||||
|
} |
||||
|
}) |
||||
@ -0,0 +1,10 @@ |
|||||
|
{ |
||||
|
"usingComponents": { |
||||
|
"refresh-view": "/components/refresher/index", |
||||
|
"wux-tabi": "/components/tabi/index", |
||||
|
"wux-image": "/components/image/index", |
||||
|
"wux-divider": "/components/divider/index", |
||||
|
"wux-dialog": "/components/dialog/index", |
||||
|
"wux-button": "/components/button/index" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,69 @@ |
|||||
|
<!--pages/goods/index/index.wxml--> |
||||
|
<wxs module="formate" src="../../../../pages/formate.wxs"></wxs> |
||||
|
<cu-custom bgColor="bg-white" isBack="{{true}}"> |
||||
|
<view slot="content">商品管理</view> |
||||
|
</cu-custom> |
||||
|
|
||||
|
<view class="nav bg-white fixed" style="top:{{CustomBar}}px;"> |
||||
|
<wux-tabi tab-data="{{tabList}}" tab-index="{{tabIndex}}" bind:change="onTabChange"></wux-tabi> |
||||
|
<wux-divider show-text="{{ false }}"></wux-divider> |
||||
|
<wux-tabi scroll="{{cateScroll}}" tab-data="{{tabiList}}" tab-index="{{pageIndex}}" bind:change="onCategoryChange"></wux-tabi> |
||||
|
</view> |
||||
|
<view style="height:180rpx;width:100%"></view> |
||||
|
|
||||
|
<refresh-view bind:refresh="onRefreshList" height="{{height}}" triggered="{{requesting}}" scrollTop="{{top}}" bind:scrolltolower="fetchGoodsList"> |
||||
|
<view wx:if="{{!orderList.length}}"> |
||||
|
<view class="list-empty" style="height:{{height}}rpx"> |
||||
|
<view class="load-spinner text-gray" style="margin-bottom:24px" wx:if="{{loading}}" /> |
||||
|
<image class="img-empty" src="/assets/image/list_empty.png" wx:else></image> |
||||
|
<view class="text-empty">{{loading? '正在加载' : '暂无数据'}}</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
<view wx:else> |
||||
|
<view wx:for-item="pageItem" wx:for-index="pageIndex" wx:for="{{orderList}}" wx:key="pageIndex"> |
||||
|
<view wx:for="{{pageItem}}" wx:key="index"> |
||||
|
<wux-divider show-text="{{ false }}" wx:if="{{pageIndex != 0 || index != 0 }}"></wux-divider> |
||||
|
<view class="flex item-content" data-page="{{pageIndex}}" data-index="{{index}}" bindtap="lookItem"> |
||||
|
<wux-image width="{{100}}" height="{{100}}" shape="rounded" lazyLoad="true" src="{{item.coverImgUrl}}" mode="aspectFill"> |
||||
|
<image class="image-load" slot="loading" src="/assets/image/def_image.png"></image> |
||||
|
</wux-image> |
||||
|
<view style="flex:1;padding-left:20rpx;padding-top:8rpx;height:100px"> |
||||
|
<view class="flex flex-justify" style="height:20px;"> |
||||
|
<view class="page-name"> |
||||
|
<text>{{item.secondCategoryName}}</text> |
||||
|
<text style="font-size:22rpx;margin-left:4rpx">{{item.locProvinceName + item.locCityName}}</text> |
||||
|
</view> |
||||
|
<view class="page-num">库存:{{formate.formateWeight(item.stock, kg)}}</view> |
||||
|
</view> |
||||
|
<view style="height:50px"> |
||||
|
<view class="page-outline">{{item.description || ''}}</view> |
||||
|
</view> |
||||
|
<view class="flex flex-justify"> |
||||
|
<view class="page-price" wx:if="{{formate.formatePrice(item.unitPrice, kg) !=''}}">¥{{formate.formatePrice(item.unitPrice, kg)}}</view> |
||||
|
<view class="page-price" wx:if="{{formate.formatePrice(item.unitPrice, kg) ==''}}">价格面议</view> |
||||
|
<view class="flex"> |
||||
|
<wux-button outline size="tag" data-page="{{pageIndex}}" data-index="{{index}}" bind:click="editItem" wx:if="{{item.bidType == 1 && item.status == 2}}">编辑</wux-button> |
||||
|
<wux-button outline style="margin-left:9px" size="tag" data-page="{{pageIndex}}" data-index="{{index}}" wx:if="{{item.bidType == 1}}" bind:click="shelvesItem">{{item.status == 2 ? '上架': '下架'}}</wux-button> |
||||
|
<wux-button outline style="margin-left:9px" size="tag" data-page="{{pageIndex}}" data-index="{{index}}" wx:if="{{item.bidType == 2 && item.status == 1}}" bind:click="shelvesItem">下架</wux-button> |
||||
|
<wux-button outline style="margin-left:9px" size="tag" data-page="{{pageIndex}}" data-index="{{index}}" wx:if="{{item.bidType == 2 && item.status == 2}}" bind:click="editItem">重新发布</wux-button> |
||||
|
<wux-button outline style="margin-left:9px" size="tag" data-page="{{pageIndex}}" data-index="{{index}}" bind:click="removeItem" wx:if="{{item.status == 2}}">删除</wux-button> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
|
||||
|
</view> |
||||
|
<!--加载更多的UI--> |
||||
|
<view wx:if="{{form.pageNum>1}}" style="padding:20rpx"> |
||||
|
<wux-divider> |
||||
|
<view class="loadmore"> |
||||
|
<text class="icon--refresher" wx:if="{{!finished}}"></text> |
||||
|
<text class="text-sm" style="margin-left:8rpx">{{finished?'到底啦~':'加载中...'}}</text> |
||||
|
</view> |
||||
|
</wux-divider> |
||||
|
</view> |
||||
|
</view> |
||||
|
</refresh-view> |
||||
|
|
||||
|
<wux-dialog id="wux-dialog" /> |
||||
@ -0,0 +1,51 @@ |
|||||
|
.item-content { |
||||
|
height: 120px; |
||||
|
background: rgba(255, 255, 255, 1); |
||||
|
padding:20rpx |
||||
|
} |
||||
|
|
||||
|
.page-name { |
||||
|
font-size: 32rpx; |
||||
|
font-family: PingFang-SC-Medium, PingFang-SC; |
||||
|
font-weight: 500; |
||||
|
color: rgba(51, 51, 51, 1); |
||||
|
line-height: 22px; |
||||
|
} |
||||
|
|
||||
|
.page-num { |
||||
|
font-size: 24rpx; |
||||
|
font-family: PingFang-SC-Regular, PingFang-SC; |
||||
|
font-weight: 400; |
||||
|
color: rgba(153, 153, 153, 1); |
||||
|
} |
||||
|
|
||||
|
.page-outline { |
||||
|
margin-top: 8rpx; |
||||
|
font-size: 28rpx; |
||||
|
font-family: PingFang-SC-Regular, PingFang-SC; |
||||
|
font-weight: 400; |
||||
|
color: rgba(51, 51, 51, 1); |
||||
|
display: -webkit-box; |
||||
|
overflow: hidden; |
||||
|
text-overflow: ellipsis; |
||||
|
word-wrap: break-word; |
||||
|
white-space: normal !important; |
||||
|
-webkit-line-clamp: 2; |
||||
|
-webkit-box-orient: vertical; |
||||
|
} |
||||
|
|
||||
|
.page-price { |
||||
|
line-height: 30rpx; |
||||
|
font-size: 32rpx; |
||||
|
font-family: DINAlternate-Bold, DINAlternate; |
||||
|
font-weight: bold; |
||||
|
color: rgba(255, 66, 43, 1); |
||||
|
} |
||||
|
|
||||
|
.image-load { |
||||
|
width: 100px; |
||||
|
height: 100px; |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
justify-content: center; |
||||
|
} |
||||
@ -0,0 +1,26 @@ |
|||||
|
const app = getApp() |
||||
|
|
||||
|
Component({ |
||||
|
options: { |
||||
|
addGlobalClass: true, |
||||
|
multipleSlots: true |
||||
|
}, |
||||
|
properties: { |
||||
|
item: { type: Object, value: null } |
||||
|
}, |
||||
|
data: { |
||||
|
kg: app.globalData.kg |
||||
|
}, |
||||
|
lifetimes: { |
||||
|
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
|
||||
|
attached: function () { |
||||
|
this.setData({ kg: app.globalData.kg }) |
||||
|
} |
||||
|
}, |
||||
|
methods: { |
||||
|
lookItem: function (e) { |
||||
|
wx.navigateTo({ url: '/pages/mall/detail/index?id=' + this.data.item.id }) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
}) |
||||
@ -0,0 +1,6 @@ |
|||||
|
{ |
||||
|
"component": true, |
||||
|
"usingComponents": { |
||||
|
"wux-image": "/components/image/index" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,27 @@ |
|||||
|
<wxs module="formate" src="../../../../pages/formate.wxs"></wxs> |
||||
|
<view class="flex item-content" bindtap="lookItem"> |
||||
|
<wux-image width="{{100}}" height="{{100}}" lazyLoad="true" src="{{item.coverImgUrl}}" mode="aspectFill"> |
||||
|
<image class="image-load" slot="loading" src="/assets/image/def_image.png"></image> |
||||
|
</wux-image> |
||||
|
<view style="flex:1;padding-left:24rpx;height:100px"> |
||||
|
<view class="flex" style="height:20px;align-items: center"> |
||||
|
<image style="width:40px;height:20px;margin-right:12rpx" src="/assets/image/ico_tag{{item.bidType == 2 ? '2' : '1'}}.png"></image> |
||||
|
<view class="page-name">{{item.firstCategoryName || item.secondCategoryName}}</view> |
||||
|
</view> |
||||
|
<view class="flex page-num" style="margin-top:8rpx;justify-content: space-between"> |
||||
|
<view class="text-cut" style="font-size:24rpx;max-width: 240rpx">{{item.locProvinceName + item.locCityName}} |
||||
|
</view> |
||||
|
<view style="font-size:24rpx;margin-left:24rpx" wx:if="{{item.stock}}">库存:{{formate.formateWeight(item.stock, kg)}}</view> |
||||
|
</view> |
||||
|
<view class="flex flex-center" style="margin-top:16rpx;justify-content: flex-start"> |
||||
|
<text class="text-xs text-gray" wx:if="{{item.bidType == 2}}">起拍单价</text> |
||||
|
<text class="page-price" wx:if="{{formate.formatePrice(item.unitPrice, kg)!=''}}">¥{{formate.formatePrice(item.unitPrice, kg)}}</text> |
||||
|
<view class="text-df" style="color: rgba(255, 66, 43, 1);margin-left:8rpx" wx:if="{{formate.formatePrice(item.unitPrice, kg)!=''}}">{{ kg? '元/KG' : '元/吨' }} |
||||
|
</view> |
||||
|
<text class="page-price" wx:if="{{formate.formatePrice(item.unitPrice, kg)==''}}">价格面议</text> |
||||
|
</view> |
||||
|
<view style="height:32px"> |
||||
|
<view class="page-outline">{{item.description || ''}}</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
@ -0,0 +1,49 @@ |
|||||
|
.item-content { |
||||
|
background: rgba(255, 255, 255, 1); |
||||
|
padding:32rpx |
||||
|
} |
||||
|
|
||||
|
.page-name { |
||||
|
font-size: 36rpx; |
||||
|
font-weight: bold; |
||||
|
color: rgba(51, 51, 51, 1); |
||||
|
line-height: 20px; |
||||
|
} |
||||
|
|
||||
|
.page-num { |
||||
|
font-size: 24rpx; |
||||
|
font-family: PingFang-SC-Regular, PingFang-SC; |
||||
|
font-weight: 400; |
||||
|
color: #040404; |
||||
|
} |
||||
|
|
||||
|
.page-outline { |
||||
|
margin-top: 8rpx; |
||||
|
font-size: 24rpx; |
||||
|
font-family: PingFang-SC-Regular, PingFang-SC; |
||||
|
font-weight: 400; |
||||
|
color: #999999; |
||||
|
display: -webkit-box; |
||||
|
overflow: hidden; |
||||
|
text-overflow: ellipsis; |
||||
|
word-wrap: break-word; |
||||
|
white-space: normal !important; |
||||
|
-webkit-line-clamp: 2; |
||||
|
-webkit-box-orient: vertical; |
||||
|
} |
||||
|
|
||||
|
.page-price { |
||||
|
line-height: 30rpx; |
||||
|
font-size: 34rpx; |
||||
|
font-family: DINAlternate-Bold, DINAlternate; |
||||
|
font-weight: bold; |
||||
|
color: rgba(255, 66, 43, 1); |
||||
|
} |
||||
|
|
||||
|
.image-load { |
||||
|
width: 100px; |
||||
|
height: 100px; |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
justify-content: center; |
||||
|
} |
||||
@ -0,0 +1,66 @@ |
|||||
|
// submodel/pages/paper/index/index.js
|
||||
|
Page({ |
||||
|
|
||||
|
/** |
||||
|
* 页面的初始数据 |
||||
|
*/ |
||||
|
data: { |
||||
|
|
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 生命周期函数--监听页面加载 |
||||
|
*/ |
||||
|
onLoad: function (options) { |
||||
|
|
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 生命周期函数--监听页面初次渲染完成 |
||||
|
*/ |
||||
|
onReady: function () { |
||||
|
|
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 生命周期函数--监听页面显示 |
||||
|
*/ |
||||
|
onShow: function () { |
||||
|
|
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 生命周期函数--监听页面隐藏 |
||||
|
*/ |
||||
|
onHide: function () { |
||||
|
|
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 生命周期函数--监听页面卸载 |
||||
|
*/ |
||||
|
onUnload: function () { |
||||
|
|
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 页面相关事件处理函数--监听用户下拉动作 |
||||
|
*/ |
||||
|
onPullDownRefresh: function () { |
||||
|
|
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 页面上拉触底事件的处理函数 |
||||
|
*/ |
||||
|
onReachBottom: function () { |
||||
|
|
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 用户点击右上角分享 |
||||
|
*/ |
||||
|
onShareAppMessage: function () { |
||||
|
|
||||
|
} |
||||
|
}) |
||||
@ -0,0 +1,3 @@ |
|||||
|
{ |
||||
|
"usingComponents": {} |
||||
|
} |
||||
@ -0,0 +1,2 @@ |
|||||
|
<!--submodel/pages/paper/index/index.wxml--> |
||||
|
<text>submodel/pages/paper/index/index.wxml</text> |
||||
@ -0,0 +1 @@ |
|||||
|
/* submodel/pages/paper/index/index.wxss */ |
||||
Write
Preview
Loading…
Cancel
Save