From d9dad15d07b9bfc375a912d9ed2570a49f503a13 Mon Sep 17 00:00:00 2001 From: xpz2018 <107107461@qq.com> Date: Mon, 11 Oct 2021 22:05:21 +0800 Subject: [PATCH] no message --- app.json | 1 + submodel/pages/goods/create/index.js | 538 +++++++++++++++++++ submodel/pages/goods/create/index.json | 7 + submodel/pages/goods/create/index.wxml | 149 +++++ submodel/pages/goods/create/index.wxss | 31 ++ submodel/pages/goods/detail/index.js | 316 +++++++++++ submodel/pages/goods/detail/index.json | 7 + submodel/pages/goods/detail/index.wxml | 73 +++ submodel/pages/goods/detail/index.wxss | 79 +++ submodel/pages/goods/fragment/index.js | 141 +++++ submodel/pages/goods/fragment/index.json | 15 + submodel/pages/goods/fragment/index.wxml | 53 ++ submodel/pages/goods/fragment/index.wxss | 0 submodel/pages/goods/goods.wxs | 133 +++++ submodel/pages/goods/index/index.js | 238 ++++++++ submodel/pages/goods/index/index.json | 10 + submodel/pages/goods/index/index.wxml | 69 +++ submodel/pages/goods/index/index.wxss | 51 ++ submodel/pages/goods/product-item/index.js | 26 + submodel/pages/goods/product-item/index.json | 6 + submodel/pages/goods/product-item/index.wxml | 27 + submodel/pages/goods/product-item/index.wxss | 49 ++ submodel/pages/paper/index/index.js | 66 +++ submodel/pages/paper/index/index.json | 3 + submodel/pages/paper/index/index.wxml | 2 + submodel/pages/paper/index/index.wxss | 1 + 26 files changed, 2091 insertions(+) create mode 100644 submodel/pages/goods/create/index.js create mode 100644 submodel/pages/goods/create/index.json create mode 100644 submodel/pages/goods/create/index.wxml create mode 100644 submodel/pages/goods/create/index.wxss create mode 100644 submodel/pages/goods/detail/index.js create mode 100644 submodel/pages/goods/detail/index.json create mode 100644 submodel/pages/goods/detail/index.wxml create mode 100644 submodel/pages/goods/detail/index.wxss create mode 100644 submodel/pages/goods/fragment/index.js create mode 100644 submodel/pages/goods/fragment/index.json create mode 100644 submodel/pages/goods/fragment/index.wxml create mode 100644 submodel/pages/goods/fragment/index.wxss create mode 100644 submodel/pages/goods/goods.wxs create mode 100644 submodel/pages/goods/index/index.js create mode 100644 submodel/pages/goods/index/index.json create mode 100644 submodel/pages/goods/index/index.wxml create mode 100644 submodel/pages/goods/index/index.wxss create mode 100644 submodel/pages/goods/product-item/index.js create mode 100644 submodel/pages/goods/product-item/index.json create mode 100644 submodel/pages/goods/product-item/index.wxml create mode 100644 submodel/pages/goods/product-item/index.wxss create mode 100644 submodel/pages/paper/index/index.js create mode 100644 submodel/pages/paper/index/index.json create mode 100644 submodel/pages/paper/index/index.wxml create mode 100644 submodel/pages/paper/index/index.wxss diff --git a/app.json b/app.json index 33076f0..47e9246 100644 --- a/app.json +++ b/app.json @@ -72,6 +72,7 @@ "pages/purchase/detail/index", "pages/bidding/index/index", "pages/bidding/detail/index", + "pages/paper/index/index", "pages/paper/price-index/index", "pages/paper/cate-list/index", "pages/shop/index/index", diff --git a/submodel/pages/goods/create/index.js b/submodel/pages/goods/create/index.js new file mode 100644 index 0000000..bca4903 --- /dev/null +++ b/submodel/pages/goods/create/index.js @@ -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) + }) + } + + } +}) \ No newline at end of file diff --git a/submodel/pages/goods/create/index.json b/submodel/pages/goods/create/index.json new file mode 100644 index 0000000..aeac055 --- /dev/null +++ b/submodel/pages/goods/create/index.json @@ -0,0 +1,7 @@ +{ + "usingComponents": { + "select-view": "/components/select-view/index", + "wux-cascader": "/components/cascader/index", + "wux-uploader": "/components/uploader/index" + } +} \ No newline at end of file diff --git a/submodel/pages/goods/create/index.wxml b/submodel/pages/goods/create/index.wxml new file mode 100644 index 0000000..3f4185f --- /dev/null +++ b/submodel/pages/goods/create/index.wxml @@ -0,0 +1,149 @@ + + + {{form.bidType == 1 ? '我要卖货' : '发布竞价'}} + + + + + + {{!disabled?'商品图片(至少上传2张)':'商品图片'}} + {{imgLength}}{{!disabled? '/6':'张'}} + + + + + + 上传视频(选填) + 支持MP4格式 + + + + + + + 废纸品类: + + {{cateName||'请选择废纸品类'}} + + + + + + + 商品单价({{kg? '元/KG' : '元/吨'}}): + + + + + + 起拍单价({{kg? '元/KG' : '元/吨'}}): + + + + + + 库存重量({{ kg? 'KG' : '吨'}}): + + + + + + 最少起订重量({{ kg? 'KG' : '吨'}}): + + + + + + 竞价有效时: + + {{intervalName||'请选择竞价有效时'}} + + + + + + + 含杂比例: + + {{dopantName||'请选择含杂比例'}} + + + + + + + 湿水比例: + + {{waterName||'请选择湿水比例'}} + + + + + + + 所在地区: + + {{form.areaStr||'请选择所在地区'}} + + + + + + 详细地址: + + + + 商品描述: + + + 选择模板 + + + + + {{form.description.length?form.description:'点击输入商品描述,最多100字'}} + + + + + + + + + + + + + 预估总价: + {{goods.formateAmount(sumAmount)}} + + + + + + + + \ No newline at end of file diff --git a/submodel/pages/goods/create/index.wxss b/submodel/pages/goods/create/index.wxss new file mode 100644 index 0000000..f8530e9 --- /dev/null +++ b/submodel/pages/goods/create/index.wxss @@ -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; +} \ No newline at end of file diff --git a/submodel/pages/goods/detail/index.js b/submodel/pages/goods/detail/index.js new file mode 100644 index 0000000..f239355 --- /dev/null +++ b/submodel/pages/goods/detail/index.js @@ -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', + }) + } +}) \ No newline at end of file diff --git a/submodel/pages/goods/detail/index.json b/submodel/pages/goods/detail/index.json new file mode 100644 index 0000000..c546c16 --- /dev/null +++ b/submodel/pages/goods/detail/index.json @@ -0,0 +1,7 @@ +{ + "usingComponents": { + "wux-button": "/components/button/index", + "wux-input-number": "/components/input-number/index", + "wux-landscape": "/components/landscape/index" + } +} \ No newline at end of file diff --git a/submodel/pages/goods/detail/index.wxml b/submodel/pages/goods/detail/index.wxml new file mode 100644 index 0000000..513f2a2 --- /dev/null +++ b/submodel/pages/goods/detail/index.wxml @@ -0,0 +1,73 @@ + + + 商品详情 + + + + + + + + + + + + + + + + + + ¥{{form.unitPrice || orderInfo.price}} + 库存:{{form.stockNumber >= 0 ? form.stockNumber : orderInfo.stockNumber}}{{orderInfo.unit}} + + {{orderInfo.viewNum}} 浏览 + + + {{orderInfo.name}} + + + + + + 购买数量 + + + + + 商品描述 + {{orderInfo.description}} + + + + + + + + + + + + + + + + + 合计: + ¥{{amount}} + + + + + + + + + \ No newline at end of file diff --git a/submodel/pages/goods/detail/index.wxss b/submodel/pages/goods/detail/index.wxss new file mode 100644 index 0000000..ff9bfb1 --- /dev/null +++ b/submodel/pages/goods/detail/index.wxss @@ -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; +} \ No newline at end of file diff --git a/submodel/pages/goods/fragment/index.js b/submodel/pages/goods/fragment/index.js new file mode 100644 index 0000000..b8c13ea --- /dev/null +++ b/submodel/pages/goods/fragment/index.js @@ -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 }) + } + } +}) \ No newline at end of file diff --git a/submodel/pages/goods/fragment/index.json b/submodel/pages/goods/fragment/index.json new file mode 100644 index 0000000..5f4f310 --- /dev/null +++ b/submodel/pages/goods/fragment/index.json @@ -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" + } +} \ No newline at end of file diff --git a/submodel/pages/goods/fragment/index.wxml b/submodel/pages/goods/fragment/index.wxml new file mode 100644 index 0000000..fb279d1 --- /dev/null +++ b/submodel/pages/goods/fragment/index.wxml @@ -0,0 +1,53 @@ + + + + + 一口价专区 + 担保交易 支持退货 + + + + 特价专区 + 稀有资源 限时特价 + + + + + + + + + + + + + 正在加载 + + + 特价商品发布中, + 先去一口价专区逛逛吧。 + + 暂无数据 + + + + + + + + + + + + + + + + + + {{finished?'到底啦~':'加载中...'}} + + + + + diff --git a/submodel/pages/goods/fragment/index.wxss b/submodel/pages/goods/fragment/index.wxss new file mode 100644 index 0000000..e69de29 diff --git a/submodel/pages/goods/goods.wxs b/submodel/pages/goods/goods.wxs new file mode 100644 index 0000000..286f23a --- /dev/null +++ b/submodel/pages/goods/goods.wxs @@ -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 +} \ No newline at end of file diff --git a/submodel/pages/goods/index/index.js b/submodel/pages/goods/index/index.js new file mode 100644 index 0000000..35439b0 --- /dev/null +++ b/submodel/pages/goods/index/index.js @@ -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) + } +}) \ No newline at end of file diff --git a/submodel/pages/goods/index/index.json b/submodel/pages/goods/index/index.json new file mode 100644 index 0000000..6707293 --- /dev/null +++ b/submodel/pages/goods/index/index.json @@ -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" + } +} \ No newline at end of file diff --git a/submodel/pages/goods/index/index.wxml b/submodel/pages/goods/index/index.wxml new file mode 100644 index 0000000..2655303 --- /dev/null +++ b/submodel/pages/goods/index/index.wxml @@ -0,0 +1,69 @@ + + + + 商品管理 + + + + + + + + + + + + + + + {{loading? '正在加载' : '暂无数据'}} + + + + + + + + + + + + + + {{item.secondCategoryName}} + {{item.locProvinceName + item.locCityName}} + + 库存:{{formate.formateWeight(item.stock, kg)}} + + + {{item.description || ''}} + + + ¥{{formate.formatePrice(item.unitPrice, kg)}} + 价格面议 + + 编辑 + {{item.status == 2 ? '上架': '下架'}} + 下架 + 重新发布 + 删除 + + + + + + + + + + + + + {{finished?'到底啦~':'加载中...'}} + + + + + + + \ No newline at end of file diff --git a/submodel/pages/goods/index/index.wxss b/submodel/pages/goods/index/index.wxss new file mode 100644 index 0000000..92c4183 --- /dev/null +++ b/submodel/pages/goods/index/index.wxss @@ -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; +} diff --git a/submodel/pages/goods/product-item/index.js b/submodel/pages/goods/product-item/index.js new file mode 100644 index 0000000..0b5d1e5 --- /dev/null +++ b/submodel/pages/goods/product-item/index.js @@ -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 }) + } + } + +}) \ No newline at end of file diff --git a/submodel/pages/goods/product-item/index.json b/submodel/pages/goods/product-item/index.json new file mode 100644 index 0000000..8dee24a --- /dev/null +++ b/submodel/pages/goods/product-item/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "wux-image": "/components/image/index" + } +} \ No newline at end of file diff --git a/submodel/pages/goods/product-item/index.wxml b/submodel/pages/goods/product-item/index.wxml new file mode 100644 index 0000000..e10b984 --- /dev/null +++ b/submodel/pages/goods/product-item/index.wxml @@ -0,0 +1,27 @@ + + + + + + + + + {{item.firstCategoryName || item.secondCategoryName}} + + + {{item.locProvinceName + item.locCityName}} + + 库存:{{formate.formateWeight(item.stock, kg)}} + + + 起拍单价 + ¥{{formate.formatePrice(item.unitPrice, kg)}} + {{ kg? '元/KG' : '元/吨' }} + + 价格面议 + + + {{item.description || ''}} + + + \ No newline at end of file diff --git a/submodel/pages/goods/product-item/index.wxss b/submodel/pages/goods/product-item/index.wxss new file mode 100644 index 0000000..c455c9d --- /dev/null +++ b/submodel/pages/goods/product-item/index.wxss @@ -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; +} diff --git a/submodel/pages/paper/index/index.js b/submodel/pages/paper/index/index.js new file mode 100644 index 0000000..e8e5494 --- /dev/null +++ b/submodel/pages/paper/index/index.js @@ -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 () { + + } +}) \ No newline at end of file diff --git a/submodel/pages/paper/index/index.json b/submodel/pages/paper/index/index.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/submodel/pages/paper/index/index.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/submodel/pages/paper/index/index.wxml b/submodel/pages/paper/index/index.wxml new file mode 100644 index 0000000..c666c78 --- /dev/null +++ b/submodel/pages/paper/index/index.wxml @@ -0,0 +1,2 @@ + +submodel/pages/paper/index/index.wxml diff --git a/submodel/pages/paper/index/index.wxss b/submodel/pages/paper/index/index.wxss new file mode 100644 index 0000000..8103c61 --- /dev/null +++ b/submodel/pages/paper/index/index.wxss @@ -0,0 +1 @@ +/* submodel/pages/paper/index/index.wxss */ \ No newline at end of file