You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

709 lines
18 KiB

<template>
<view
style="display: flex;flex-direction: column;height: 100vh;background: -webkit-linear-gradient(left,#FEA65F,#FB9440);">
<view class="top">
<NavBar ref="nav" navTitle=" " :showIcon="false" :start-change-height="page.startHeight"
:end-change-height="page.endHeight">
</NavBar>
</view>
<loading-state ref="pageView" @request="request">
<view
style="background: #fff; height: calc(100vh - 45px - 50vw);width: 100%; border-radius: 15px;display: flex;flex-direction: column; box-sizing: border-box;margin-top: -15px;box-sizing: border-box;">
<view class="center">
<view style="width: 22%;display: flex;flex-direction: column;overflow-y: auto;padding-top: 10px;">
<view style="width: 100%;display: flex;flex-direction: column; ">
<view v-for="(item,index) in data.typeVos" @click="labelClick(index,item)"
style="display: flex;flex-direction: column;justify-content: center;">
<text class="label" :class="{'label2':selectIndex==index}">{{item.name}}</text>
</view>
</view>
</view>
<view style="width: 78%;background-color: #fff;overflow-y: auto;">
<view style="z-index: 1;background: #FFFFFF;position: sticky;top: 0;padding: 10px;">
<view style="display: flex;flex-direction: row;overflow-x: auto;">
<view v-for="(item,index2) in data.brandVos"
style="display: flex;flex-direction: column; justify-content: center;align-items: center;margin-right: 10px;"
@click.stop="brandClick(index2)">
<image src="https://supervise.yxtsoft.com/lpk/image/family_icon.png"
mode="aspectFill" :class="selectIndex2 == index2?'top_img1':'top_img2'"
style="width: 60px;height:60px;border-radius: 50%;padding:5px;"></image>
<text
:class="selectIndex2 == index2?'top_text1':'top_text2'">{{item.brandName}}</text>
</view>
</view>
</view>
<view style="width: 100%; display: flex;flex-direction: column;overflow-y: auto;">
<view v-for="(item,index) in goods"
style="display: flex;flex-direction: column;justify-content: center;width: 95%; margin-top: 15px; margin-left: 3%;">
<view style="display: flex;flex-direction: row;align-items: center;width: 100%; ">
<image :src="item.iconUrl" style="width: 90px;height: 90px; border-radius: 10px; "
mode="aspectFill" @click="itemClick(item.goodsSid)"></image>
<view
style="display: flex;flex-direction: column;flex: 1; padding-bottom: 15px; margin-left: 10px;"
:style="{'border-bottom':(index == goods.length-1 ? 'none' : '1px #EFEFEF solid')}">
<text style="font-size: 13px;color: #000;">{{item.name}}</text>
<text
style="font-size: 10px;color: #999;margin-top: 5px;">{{item.remark}}</text>
<view
style="display: flex;flex-direction: row;align-items: center;margin-top: 8px;">
<text style="border: 1px #EE752F solid; border-radius: 5px; padding: 0px 8px;
font-size: 10px;color: #EE752F;">{{item.jprice}}元/{{item.specificationUnit}}</text>
<text
style="border: 1px #EE752F solid; border-radius: 5px; padding: 0px 8px;
font-size: 10px;color: #EE752F; margin-left: 10px; margin-right: 10px; ">{{item.weight}}{{item.specificationUnit}}/{{item.unitName}}</text>
</view>
<view style="display: flex;flex-direction: row;align-items: center;justify-content: space-between; margin-top: 15px;
margin-right: 15px;">
<text style="font-size: 14px;color: #FF5006;">¥{{item.mefenPrice}}</text>
<view style="display: flex;flex-direction: row;align-items: center;">
<image src="../../static/jian_icon.png" mode="aspectFill"
style="width: 20px;height: 20px;" @click.stop="jian(item)"></image>
<text
style="font-size: 14px;margin-left: 8px;margin-right: 8px;">{{item.goodsNumber}}</text>
<image src="../../static/jia_icon.png" mode="aspectFill"
style="width: 20px;height: 20px;" @click.stop="jia(item)"></image>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
<view class="bottom">
<view style="display: flex;flex-direction: row;align-items: center; justify-content: center;">
<!-- <view style="width: 35px;height: 35px;position: relative; visibility: hidden; ">
<image style="width: 25px;height: 25px;margin-left: 5px; margin-top: 5px; "
src="../../static/basket_icon.png" mode="aspectFill"></image>
<view style="border-radius: 50%;text-align: center;background: #f00;color: #fff;font-size: 8px;
position: absolute;
top: 2px;
right: 0px;
padding: 2px 5px;
width: auto;">{{page.count}}</view>
</view> -->
<view id="bomView" style="display: flex;flex-direction: row;align-items: center;">
<view style="color: #888;font-size: 10px;height: 10px;line-height: 10px;margin-top: 5px;">
温馨提示:已订</view>
<view
style="color: #FF5006;font-size: 15px;height: 15px;line-height: 15px;font-weight: bold;">
{{page.weight}}斤
</view>
<view style="color: #888;font-size: 10px;height: 10px;line-height: 10px;margin-top: 5px;">
,{{data.brandVos[selectIndex2].qssl}}起订。</view>
<view style="display: flex;flex-direction: row;align-items: center;" @click="showPop2()">
<text
style="color: #6190D8;font-size: 10px;height: 10px;line-height: 10px;margin-top: 5px;text-decoration:underline;font-style:oblique;">
起订协议</text>
<text
style="color: #6190D8;font-size: 10px;height: 10px;line-height: 10px;margin-top: 5px;">
>></text>
</view>
</view>
</view>
<view
style="display: flex;flex-direction: row; justify-content: center;align-items: center;padding-bottom: 10px;margin-top: 5px;padding: 0px 10px;">
<button open-type="share">分享新人有礼</button>
<view style="border: 1px #FF5006 solid;margin-left: 5px;margin-right: 5px;padding: 0px 10px;height: 42px;flex: 1;
display: flex;flex-direction: row;align-items: center;box-sizing: border-box;" @click="gotoCart()">
<image src="../../static/shoppCart_icon.png" mode="aspectFill"
style="height: 20px;width: 20px;flex-shrink: 0;">
</image>
<view style="display: flex;flex-direction: column;flex: 1;">
<text
style="font-size: 15px;color: #FF5006;margin-left: 10px;height: 20px;line-height: 20px;margin-top: 5px;font-weight: bold;">¥{{page.price}}</text>
<text
style="font-size: 10px;color: #666;margin-left: 10px; height: 10px;line-height: 10px;margin-bottom: 5px;">{{page.remarks}}</text>
</view>
</view>
<text style="background: #FF9900; color: #fff;font-size: 13px; padding: 0px 15px;height: 40px;line-height: 40px;
border: 1px #FF5006 solid; border-top-right-radius: 25px; border-bottom-right-radius: 25px;flex-shrink: 0;"
@click="settlement()">结算</text>
</view>
</view>
</view>
</loading-state>
<uni-popup ref="inputDialog" type="dialog">
<uni-popup-dialog ref="inputClose" mode="more" title="订购协议" :showConfirm="true"
:beforeClose="dialogBeforeClose" @confirm="dialogInputConfirm"
:content="data.brandVos[selectIndex2].dgxy" :confirm-text="confirmText"></uni-popup-dialog>
</uni-popup>
<uni-popup ref="inputDialog2" type="dialog">
<uni-popup-dialog ref="inputClose" mode="base" title="起订协议" :showConfirm="true"
:beforeClose="dialogBeforeClose2" @confirm="dialogInputConfirm2"
content="1、20斤起订量。\n2、新用户正好20斤5折。\n3、20-100斤加10%附加额。\n4、101斤-200斤加5%附加额。"></uni-popup-dialog>
</uni-popup>
</view>
</template>
<script>
export default {
data() {
return {
dialogContent: "这里是协议内容,这里是协议内容,这里是协议内容,这里是协议内容,这里是协议内容,这里是协议内容,这里是协议内容,这里是协议内容这里是协议内容,这里是协议内容",
confirmText: "我知道了(5s)",
dialogBeforeClose: false,
dialogBeforeClose2: false,
countdown: 5,
searchInfo: {
sid: "0",
name: "",
affiliation: "",
customerSid: ""
},
styleObject: {
// 'position': 'fixed',
// 'top':'80vw',
'margin-top': '62vw',
'border-top-left-radius': '25px',
'border-top-right-radius': '25px',
'border-bottom-left-radius': '25px',
'border-bottom-right-radius': '25px',
'background': '#fff',
'padding-top': '10px',
'margin-bottom': "60px"
},
page: {
price: '0',
reduce: "0",
weight: "0",
count: "0",
remarks: "",
startHeight: 0,
endHeight: 0
},
data: [],
goods: [],
selectIndex: 0,
selectIndex2: 0,
initPrice: '0',
initReduce: "0",
initWeight: "0",
shareSid: "",
baseDataSuccess: false
}
},
onShow() {
if (typeof this.$mp.page.getTabBar === 'function' && this.$mp.page.getTabBar()) {
this.$mp.page.getTabBar().setData({
selected: 0
})
}
// 状态对才获取
if (this.baseDataSuccess) {
this.getgoods()
}
},
onLoad(options) {
this.shareSid = options.shareSid
console.log("shareSid>>>>", this.shareSid);
let info = uni.getSystemInfoSync();
this.page.startHeight = info.windowWidth * 0.6
this.page.endHeight = info.windowWidth * 0.8
this.request()
this.shareGift()
},
methods: {
shareGift() {
if (this.shareSid && getApp().globalData.isNewUser) {
}
},
labelClick(index, item) {
this.selectIndex = index
this.searchInfo.sid = item.sid
this.getgoods()
},
onKeyInput(event) {
this.searchInfo.name = event.target.value
this.getgoods()
},
brandClick(val) {
this.selectIndex2 = val
this.getgoods()
},
request() {
if (this.baseDataSuccess) {
this.getgoods()
} else {
let _this = this
_this.$api.getGoodsTypeAndBrand().then((resp) => {
_this.data = resp
console.log("======", resp);
_this.baseDataSuccess = true
_this.getgoods()
}).catch(e => {
_this.$nextTick(() => {
_this.$refs.pageView.setLoadState(1)
})
})
}
},
getAllPriceOrWeight() {
let _this = this
var params = {
customerSid: getApp().globalData.sid,
brandId: this.data.brandVos[this.selectIndex2].id,
}
_this.$api.getGoodsWeight(params).then((resp) => {
console.log("getGoodsWeight", resp);
_this.page.price = resp.totalPrice
_this.page.weight = resp.totalWeight
_this.page.remarks = resp.remarks
_this.initPrice = resp.totalPrice
_this.initWeight = resp.totalWeight
_this.$nextTick(() => {
_this.$refs.pageView.setLoadState(2)
})
}).catch(e => {
_this.$nextTick(() => {
_this.$refs.pageView.setLoadState(1)
})
})
},
getgoods() {
let _this = this
_this.searchInfo.customerSid = getApp().globalData.sid
_this.searchInfo.brandId = this.data.brandVos[this.selectIndex2].id
_this.searchInfo.categoryId = this.data.typeVos[this.selectIndex].id
_this.$api.getGoodsByType(_this.searchInfo).then((resp) => {
_this.goods = resp
_this.getAllPriceOrWeight()
}).catch(e => {
_this.$nextTick(() => {
_this.$refs.pageView.setLoadState(1)
})
})
},
jian(item) {
const that = this
console.log("item》》》》", item)
if (Number(item.goodsNumber) == 1) {
wx.showModal({
content: '确定不要了吗',
cancelText: "再想想",
confirmText: "删除",
confirmColor: "#FF9900",
success(res) {
if (res.confirm) {
console.log('用户点击确定')
item.goodsNumber = 0
item.subtotal = 0
that.upDateShoppCart(item)
} else if (res.cancel) {
}
}
})
} else {
if (Number(item.goodsNumber) > 0) {
item.goodsNumber = Number(item.goodsNumber) - 1
}
item.subtotal = Number(item.goodsNumber) * Number(item.mefenPrice)
that.upDateShoppCart(item)
}
},
jia(item) {
item.goodsNumber = Number(item.goodsNumber) + 1
item.subtotal = Number(item.goodsNumber) * Number(item.mefenPrice)
this.upDateShoppCart(item)
},
getallPrice() {
let num = 0;
for (var i = 0; i < this.goods.length; i++) {
num += Number(this.goods[i].subtotal);
}
this.page.price = num
},
getweight() {
let num = 0;
for (var i = 0; i < this.goods.length; i++) {
num += Number(this.goods[i].weight) * Number(this.goods[i].goodsNumber);
}
this.page.weight = num
},
upDateShoppCart(item) {
var good = {
goodsSid: item.goodsSid,
goodsName: item.name,
goodsNumber: item.goodsNumber,
affiliation: this.data.brandVos[this.selectIndex2].id,
price: item.mefenPrice,
weight: item.weight,
customerSid: getApp().globalData.sid
}
let _this = this
_this.$api.addShoppingCart(good).then((resp) => {
_this.getgoods()
}).catch(e => {
_this.getgoods()
})
},
detail(item) {
// 详情
uni.navigateTo({
url: '/pages/cloud/detail_cloudCard?sid=' + item.sid + "&name=" + item.name
})
},
settlement() {
// 支付
if (this.page.weight < parseInt(this.data.brandVos[this.selectIndex2].qssl)) {
this.shortToast('满' + this.data.brandVos[this.selectIndex2].qssl + '斤才可定制云菜窖哦,请继续选菜吧。')
return
}
this.showPop()
},
showPop() {
this.$refs.inputDialog.open()
let timeOut = setInterval(() => {
if (this.countdown == 1) {
this.confirmText = "确定"
this.countdown = 5
this.dialogBeforeClose = false
clearInterval(timeOut)
} else {
this.dialogBeforeClose = true
this.countdown = this.countdown - 1;
this.confirmText = "我知道了" + "(" + this.countdown + "s)"
}
}, 1000)
},
dialogInputConfirm(val) {
if (this.confirmText == "确定") {
this.confirmText = "我知道了(5s)",
this.dialogBeforeClose = true,
this.countdown = 5
this.saveGoods()
}
},
dialogInputConfirm2(val) {
this.dialogBeforeClose2 = true
},
saveGoods() {
// var params = {
// customerSid: getApp().globalData.sid,
// brandId: this.data.brandVos[this.selectIndex2].id
// }
// // console.log("params", params);
// let _this = this
// _this.$api.saveGoods(params).then((resp) => {
// _this.request()
// }).catch(e => {})
var params = {
customerSid: getApp().globalData.sid,
// cardNumber: 1,
brandId:this.data.brandVos[this.selectIndex2].id,
totalTee: this.page.price,
// ordOrderDetailsVoList: list
}
console.log("params", params);
let _this = this
// _this.$api.createVegeOrder(params).then((resp) => {
// // console.log("resp", resp);
// this.$pay(resp)
// }).catch(e => {
// })
},
itemClick(goodsSid) {
uni.navigateTo({
url: '/pages/good/goodsDetail?sid=' + goodsSid
})
},
gotoCart() {
uni.navigateTo({
url: '/pages/good/shoppCart?affiliation=' + this.data.brandVos[this.selectIndex2].id +
"&weight=" + this.data.brandVos[this.selectIndex2].qssl
})
},
showPop2() {
this.$refs.inputDialog2.open()
},
onShareAppMessage: function(res) {
console.log("res", res)
console.log("data", res.target.dataset)
var data = res.target.dataset.info
// ①
let shareData = JSON.stringify({
// params: {
// code: data.code,
// codeKey: data.codeKey,
// customerSid: ''
// },
// functionName: 'bindCard',
// url: '/pages/detail/detail_affeection?sid=' + data.sid
url: '/pages/home/cloudCard2?shareSid=' + getApp().globalData.sid,
functionName: 'share'
})
// 转码传输
let value = encodeURIComponent(shareData)
return {
title: '汇融惠享-云菜窖',
// ②
path: '/pages/login/login?data=' + value,
imageUrl: 'https://supervise.yxtsoft.com/lpk/image/shareAffeection.png', //自定义图片路径,显示图片长宽比是 5:4。
success: function(res) {
console.log('aaaa', "分享成功")
},
fail: function(res) {
// 转发失败
console.log('aaaa', "用户点击了取消")
}
}
},
}
}
</script>
<style>
button {
background: #FF9900;
color: #fff;
height: 42px;
line-height: 40px;
font-size: 13px;
padding: 0px 15px;
border: 1px #FF5006 solid;
border-top-left-radius: 25px;
border-bottom-left-radius: 25px;
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
}
button::after {
border: 0;
}
.top {
width: 100vw;
/* height: 126.66vw; */
height: 50vw;
/* 加载背景图 */
background-image: url(https://supervise.yxtsoft.com/lpk/image/banner.png);
/* background-image: url(../../static/clound_bj1.png); */
/* 让背景图基于容器大小伸缩 */
background-size: 100% 100%;
}
.center {
display: flex;
flex-direction: row;
/* 这里注意,影响弹窗 */
height: calc(100vh - 140px - 50vw);
background-color: #f7f7f7;
border-radius: 15px;
overflow: hidden;
min-width: 0;
}
.bottom {
display: flex;
flex-direction: column;
border-top: 1px solid #F8F8F8;
padding-top: 5px;
flex-shrink: 0;
margin-bottom: 10px;
}
.label {
color: #191919;
font-size: 12px;
margin-top: 10px;
margin-bottom: 10px;
text-align: center;
padding-top: 7px;
padding-bottom: 7px;
margin-left: 5px;
}
.label2 {
background: #FFF;
color: #FFF;
background-color: #FF9900;
font-size: 12px;
margin-top: 10px;
margin-bottom: 10px;
padding-top: 7px;
padding-bottom: 7px;
text-align: center;
font-weight: bold;
border-radius: 20px;
margin-left: 5px;
}
.top_img1 {
border: 1px #FF9900 solid;
}
.top_img2 {
border: none
}
.top_text1 {
border: 1px #FF9900 solid;
background: #FF5006;
color: #fff;
font-weight: 800;
font-family: sans-serif;
padding: 5px 16px;
border-radius: 5px;
margin-top: -25px;
font-size: 13px;
word-break: keep-all;
white-space: nowrap;
}
.top_text2 {
border: 1px #FF9900 solid;
background: #fff;
color: #F6894B;
font-weight: 800;
padding: 5px 16px;
font-family: sans-serif;
border-radius: 5px;
margin-top: -25px;
font-size: 13px;
word-break: keep-all;
white-space: nowrap;
}
::-webkit-scrollbar {
width: 0;
height: 0;
background-color: transparent;
}
</style>