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.

1384 lines
43 KiB

<template>
<view class="page1">
<cmd-nav-bar iconOne="chevron-left" @iconOne="goToInfo" :title="shopName" background-color="#fff"></cmd-nav-bar>
<view v-if="enDayShow" @tap="bigFWHPic" style="width:100%;height:60rpx;margin-top: 180rpx;">
<u-notice-bar mode='horizontal' bgColor="#088FEB" color="#eee" :text="textArr"></u-notice-bar>
</view>
<view class="title" :style="{'margin-top':enDayShow?'0':'180rpx'}">
<swiper indicator-dots class="swiper-box" @change="lunbochange" circular autoplay :current="swiperDotIndex">
<swiper-item v-for="(item, index) in bigImg" :key="index">
<view class="swiper-item">
<image :src="item.productPicture" alt="" style="width: 100%;height: 100%;border-radius: 10px;" /></image>
</view>
</swiper-item>
</swiper>
</view>
<view style="padding-bottom: 120rpx;">
<view style="background: #fff;border-radius: 10px;height: 200rpx;padding: 0 2%;">
<view style="height: 100rpx;line-height: 100rpx;font-size: 32rpx;">
<text style="color: red;"></text><text style="color: red;font-weight: bold;font-size: 42rpx;">{{shopList.discountAmount}}</text>
<text style="color:#777;font-size:26rpx;margin-left: 20rpx;">售价</text>
</view>
<view style="height: 100rpx;line-height: 80rpx;font-size: 32rpx;font-weight: bold;">
<text>{{shopList.productName}}</text>
<text style="padding-left: 20rpx;">{{shopList.productSn}}</text>
</view>
</view>
<view style="background: #fff;border-radius: 10px;margin-top: 20rpx;padding: 20rpx;display: flex;flex-direction: column;">
<view style="">
<view style="height: 60rpx;line-height: 60rpx;font-size: 30rpx;font-weight: bold;">
颜色:
</view>
<view style="display: inline-block;float: left;" v-for="(item,index) in shopList.attributeList[0].value" :key="index">
<view style="border-radius: 5px;background: #F5F5F5;padding: 5px 7px;margin-right: 20rpx;">{{item.value}}</view>
</view>
</view>
<view>
<view style="height: 60rpx;line-height: 60rpx;font-size: 30rpx;font-weight: bold;">
尺码:
</view>
<view style="display: inline-block;float: left;" v-for="(item,index) in shopList.attributeList[1].value" :key="index">
<view style="border-radius: 5px;background: #F5F5F5;padding: 5px 7px;margin-right: 20rpx;">{{item.value}}</view>
</view>
</view>
</view>
<view style="background: #fff;height: 150rpx;border-radius: 10px;display: flex;margin-top: 15rpx;">
<view>
<image src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/76970b689e86424a965089b2077b111b.jpg" alt="" style="margin: 25rpx;width: 100rpx;height: 100rpx;border-radius: 100rpx;"></image>
</view>
<view style="line-height: 150rpx;font-size: 38rpx;font-weight: bold;width: 55%;">{{shopName}}</view>
<!-- <view>
<view @tap="checkPay" style="margin-top: 45rpx;width: 150rpx;background: #f5f5f5;font-size: 28rpx;height: 60rpx;border-radius: 10px;text-align: center;line-height: 60rpx;">
进店逛逛
</view>
</view> -->
</view>
<view style="width: 100%;">
<view v-for="(item, index) in bigImg" :key="index" style="width: 100%;">
<image mode="aspectFit" :src="item.productPicture" alt="" style="display:block;width: 100%;" /></image>
</view>
</view>
</view>
<view style="width: 100%;height: 120rpx;background: #fff;position: fixed;bottom: 0;">
<view @tap="toggle('bottom',shopList)" style="width: 95%;height: 80rpx;background: #FF4040;color: #fff;border-radius: 80rpx;text-align: center;line-height: 80rpx;font-size: 32rpx;margin: 20rpx auto;">
下单
</view>
</view>
<!-- 弹出层 -->
<uni-popup ref="popup" background-color="#fff">
<view class="popup-content">
<view class="popup-title">
<view class="popup-title-left">
<img class="img-radius" :src="goodsDetail.productPicture" alt="" v-if="goodsDetail.productPicture">
<view class="noPic" v-else>暂无图片</view>
</view>
<view class="popup-title-right">
<view class="popup-title-right-box" style="color: #088FEB;">{{goodsDetail.productName == null ?'':goodsDetail.productName}}
</view>
<view class="popup-title-right-box">{{goodsDetail.productSn}}</view>
<view class="popup-title-right-box" style="color: darkorange;" @tap="inputDialogToggle">
<!-- <text style="margin-right:20rpx;">{{goodsDetail.price}}</text> -->
</view>
</view>
</view>
<view class="popup-container" style="position: relative;">
<view @tap="saveCheck" style="position: absolute;top: 10rpx;right: 20rpx;color: #088FEB;text-decoration: underline;">
保存已选
</view>
<ul style="border-top:20rpx;">
<li v-for="(items,index) in goodsDetail.attributeList" :key="index">
<view class="title-fur">
<view class="name" v-if="index == 0">{{items.name}}</view>
</view>
<view class="attrs" v-if="index == 0">
<uni-data-checkbox v-model="value" :localdata="range"
@change="change"></uni-data-checkbox>
<view class="suibian" v-for="(itemTag, index1) in items.value" :key="index1"
@tap.stop="attrNameChange(index,itemTag.value,index1) "
:class="itemTag.isChecked ? 'checkedText' : '' " style="position: relative;">
{{itemTag.value}}
<view class="kucun" v-if="itemTag.isKucun"></view>
</view>
</view>
</li>
</ul>
<view style="padding-bottom: 20rpx;">
<view class="checkList" v-if="temporaryList != ''">
<view class="checkList-box" style="width: 72%;">
<text
style="width: 50%;display: inline-block;font-size: 30rpx;font-weight: bold;padding-left: 40rpx;">
规格
</text>
<text
style="font-size: 30rpx;color: #000;font-weight: bold;width: 38%;display: inline-block;text-align: right;">
库存
</text>
</view>
<uni-number-box max='1000000' @minus='minusNum' @plus="plusNum" v-model="allChangeNum" @change="allChange" />
</view>
<view class="checkList" v-for="(item,index) in temporaryList" :key="index">
<view @tap.stop="delCarData(index)" style="margin-right: 20rpx">
<uni-icons color="red" type="minus" size="26"></uni-icons>
</view>
<view class="checkList-box">
{{item.name}}
</view>
<text style="width: 25%;font-size: 22rpx;">{{item.productNum > 0 ?'有库存':"无库存"}}</text>
<uni-number-box min="0" :max="(shopId == '1838094297858183168' || shopId == '1811579958284390400') ? item.productNum : 10000" v-model="item.productCount" @change="temporaryChange" />
</view>
</view>
</view>
</view>
<view class="popup-bottom">
<view class="popup-bottom-left">
<text>{{zNum}} </text>
<text>{{zPrice}}</text>
</view>
<view class="popup-bottom-right">
<view class="bottom-btn" @tap="temporaryCheck">选好了</view>
</view>
</view>
</uni-popup>
<!-- 弹出输入框 -->
<uni-popup ref="inputDialog" background-color="#fff">
<view class="popup-pay-content">
<view class="popup-pay-title">
填写信息
</view>
<view @tap="$refs.addressPopup.open()" v-if="userList.length > 1" style="position: absolute;top: 26rpx;right: 20rpx;color: #088FEB;font-size: 32rpx;">
选择地址
</view>
<uni-forms ref="form" :modelValue="formData" :rules="rules" labelWidth="85px">
<view style="color: red;font-size: 22rpx;">
*如您不是初次购买输入手机号后即可获取您的地址信息
</view>
<uni-forms-item label="手机号码" name="consigneeMobile">
<uni-easyinput type="number" v-model="formData.consigneeMobile" @blur="getOldPhone(formData.consigneeMobile)" placeholder="请输入手机号码" />
</uni-forms-item>
<uni-forms-item label="姓名" name="consigneeName">
<uni-easyinput type="text" v-model="formData.consigneeName" placeholder="请输入人员姓名" />
</uni-forms-item>
<uni-forms-item label="地址" name="address1">
<view class="input selectcity" @tap="openPicker">
<input placeholder="请选择省市区" disabled type="text" v-model="formData.address1"></input>
</view>
</uni-forms-item>
<uni-forms-item label="详细地址" name="address">
<uni-easyinput type="textarea" v-model="formData.address" />
</uni-forms-item>
</uni-forms>
<view class="address-btn" @tap="backPrevPage">开单</view>
</view>
</uni-popup>
<!-- 地址选择弹窗 -->
<uni-popup ref="addressPopup" background-color="#fff">
<view class="popup-pay-content" style="width: 650rpx;border-radius: 20px;">
<view style="text-align: center;line-height: 80rpx;font-weight: bold;">
查询到您有多条收货地址请选择后开单
</view>
<view style="overflow: scroll;">
<view @tap="checkUser(item)" v-for="(item,index) in userList" :key="index" style="border-top: 1px solid #eee;line-height: 60rpx;">
<view>
<text style="font-weight: bold;">姓名</text>{{item.name}}
</view>
<view><text style="font-weight: bold;">电话</text>{{item.phone}}</view>
<view><text style="font-weight: bold;">地址</text>{{item.province + '/'+item.city + '/'+item.area+'/'+item.address}}</view>
</view>
</view>
</view>
</uni-popup>
<!-- <view v-if="isSelfOrder == false" style="width: 100%;height: 100%;position: fixed;top: 0;background: #fff;text-align: center;padding-top: 45%;z-index: 120;">
暂无查看权限
</view> -->
</view>
</template>
<script>
import cmdNavBar from "@/components/cmd-nav-bar/cmd-nav-bar.vue";
import {
getArea,
wxLogin
} from '@/utils/global.js'
export default {
components: {
cmdNavBar
},
data() {
return {
mini_program_openid:'',
unionid:'',
official_account_openid:'',
userId:'',
isSelfOrder:false,
enDayShow:false,
textArr:['您还未关注快衣店服务号,暂无法接收充值及上新提醒,点击关注'],
FWHPic:'https://jewel-shop.oss-cn-beijing.aliyuncs.com/f2ba2080aaa54c618c2e47df4f220087.png',
indexList: [],
pages: 1, //分页的页码
totalPages: 0,
swiperDotIndex:0,
current: 0,
shopList: [],
info: 0,
bigImg:[],
categoryId: '', //分类id
searchName: '', //搜索框输入值
shopId: '', //店铺id,
checkbox: [], //需要分享的商品id
temporaryNum: 0,
priceType: '',
yanseList:new Map(),
chimaList:new Map(),
goodsDetail: [],
attrNameList: [],
temporaryList: [],
oldTemList:[],
carList: [],
columns: [],
keyList: [],
specsList: [],
pecsList:[],
productNum: 0,
evalue: [],
userList:[],
shareType:"1",
productId:'',
goodsList:[],
allChangeNum:0,
shopName:'',
attributeList: [],
zNum: 0,
pageZongPrice:0,
newTemList:[],
customId:'',
catagoryUserId:'',
addressObj: {},
// show: false,
zPrice: 0,
carType: 0,
carNum: 0,
pageOldTemList:[],
dataObj :new Map(),
formData: {
consigneeMobile: '',
consigneeName: '',
address1: '',
address: '',
province: '',
city: '',
area: '',
id: '',
userId:''
},
status: 'loadmore',
rules: {
consigneeName: {
rules: [{
required: true,
errorMessage: '请输入姓名',
}]
}
},
}
},
filters: {
sliceMsg(val) {
var name = ''
if (typeof(val) == 'string') {
let newObj = JSON.parse(val)
for (let as in newObj) {
name += newObj[as] + ' | '
}
}
return name;
}
},
onShow(){
if(!uni.getStorageSync('officialAccountOpenid') && !uni.getStorageSync('shopId') && uni.getStorageSync("miniProgramOpenid")){
this.getUserInfo()
}
},
onLoad(option) {
if(option.shareType){
this.shareType = option.shareType;
}
if(option.khid){
this.khid = option.khid;
this.userId = option.userId;
this.customId = option.customId
if(this.customId){
this.formData.userId = this.customId
}
this.mini_program_openid = option.mini_program_openid
this.unionid = option.unionid
this.official_account_openid = option.official_account_openid
}else if(option.scene){
const scene = decodeURIComponent(option.scene)
this.khid = scene;
}
if(uni.getStorageSync('id') && !uni.getStorageSync('miniProgramOpenid') && !uni.getStorageSync('shopId')){
this.getOpenId(this.customId, uni.getStorageSync('id') ? uni.getStorageSync('id') : this.userId)
}
this.tui.request("/app/productShare/getShareList", "POST", {
searchStr: "",
categoryId:'',
id: option.khid.replace(/-/g, ''),
// id:'1854690661501112321',
pageNum: 1,
pageSize: '10'
}, false, true).then((res) => {
if (res.code == 200) {
if(res.result.share.scene != null){
this.catagoryUserId = JSON.parse(res.result.share.scene).id
this.customName = JSON.parse(res.result.share.scene).name
this.formData.userId = JSON.parse(res.result.share.scene).customId
this.userId = JSON.parse(res.result.share.scene).userId;
this.mini_program_openid = JSON.parse(res.result.share.scene).mini_program_openid
this.official_account_openid = JSON.parse(res.result.share.scene).official_account_openid
this.unionid = JSON.parse(res.result.share.scene).unionid
}
this.shopId = res.result.share.shopId
uni.setNavigationBarTitle({
title: res.result.share.shopName
});
this.priceType = res.result.share.priceType
this.shopName = res.result.share.shopName
this.shopList = res.result.shareList.records[0]
if (res.result.share.priceType == 1) { //批发价
this.shopList.discountAmount = this.shopList.wholesalePrice
} else if(res.result.share.priceType == 0) { //零售
this.shopList.discountAmount = this.shopList.price
}else{
this.shopList.discountAmount = this.shopList.wholesalePrice
if(this.shopList.customerCategoryRule != null && this.shopList.customerCategoryRule != ''){
let customerCategoryRule = JSON.parse(this.shopList.customerCategoryRule)
for (var m = 0; m < customerCategoryRule.length; m++) {
if(customerCategoryRule[m].categoryPrice != '' && customerCategoryRule[m].categoryId == this.catagoryUserId){
this.shopList.discountAmount = customerCategoryRule[m].categoryPrice
}
}
}
}
if(this.shopList.productPicture != null){
let data = {
productPicture:this.shopList.productPicture
}
this.bigImg.push(data)
}
if(this.shopList.productPictures != null){
for(let i=0;i<this.shopList.productPictures.length;i++){
this.bigImg.push(this.shopList.productPictures[i])
}
}
this.getCategory()
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
/*
微信登录判断开始
*/
this.contrastOpneId()
/*
微信登录判断结束
*/
},
methods: {
async contrastOpneId() {
let openid1 = uni.getStorageSync('miniProgramOpenid')
let openid2 = this.mini_program_openid
if (openid1 != '' && openid1 != undefined && openid1 != null) {
if (openid2 != undefined &&openid2 != "undefined" && openid2 != 'null' && openid2 != '' && openid2 != null) {
if (openid1 != openid2) {
//缓存和分享的openid不一致
// this.tui.toast('暂无查看权限', 1000)
// return
} else {
this.isSelfOrder = true
this.$forceUpdate()
}
} else {
//调接口传customId更新userid
this.updateUserId()
this.isSelfOrder = true
this.$forceUpdate()
}
} else {
//await this.getOpenId(this.customId, uni.getStorageSync('id') ? uni.getStorageSync('id') : this.userId)
//openid1 = uni.getStorageSync('miniProgramOpenid')
if (openid2 != undefined &&openid2 != "undefined" && openid2 != 'null' && openid2 != '' && openid2 != null) {
this.isSelfOrder = true
this.$forceUpdate()
} else {
//调接口传customId更新userid
this.updateUserId()
this.isSelfOrder = true
this.$forceUpdate()
}
}
},
getUserInfo(){
this.tui.request("/user/getUserInfo", "post", {
miniProgramOpenid:uni.getStorageSync('miniProgramOpenid')
}, false, true).then((res) => {
if (res.code == 200) {
if(res.result.officialAccountOpenid == 'null' || res.result.officialAccountOpenid == null || res.result.officialAccountOpenid == undefined || res.result.officialAccountOpenid ==''){
this.enDayShow = true
}else{
uni.setStorageSync('officialAccountOpenid',res.result.officialAccountOpenid)
this.enDayShow = false
}
}
}).catch((res) => {})
},
updateUserId() {
if(this.customId && uni.getStorageSync('id')){
this.tui.request("/app/customer/updateUserId", "post", {
customerId: this.customId,
userId: uni.getStorageSync('id')
}, false, true).then((res) => {
if (res.code != 200) {
this.tui.toast(res.message)
}
}).catch((res) => {})
}
},
//获取小程序openid
getOpenId(customId, userId) {
let that = this;
return new Promise((resolve, reject) => {
uni.login({
provider: 'weixin',
success(res) {
uni.getUserInfo({
provider: 'weixin',
success: function(infoRes) {
that.tui.request("/user/login", "post", {
jsCode: res.code,
customId: customId,
userId: userId,
wechatName: infoRes.userInfo.nickName,
userType: "2"
}, false, false).then((res) => {
if (res.code == 200) {
uni.setStorageSync("hiver_token", res
.result.accessToken)
uni.setStorageSync("wayValue", "2")
uni.setStorageSync("nickname", res.result
.user.nickname)
uni.setStorageSync("id", res.result.user
.id)
uni.setStorageSync('unionid', res.result
.user.unionid)
uni.setStorageSync('miniProgramOpenid', res
.result.user
.miniProgramOpenid)
uni.setStorageSync('officialAccountOpenid',
res.result.user
.officialAccountOpenid)
return resolve(res.result)
} else {
tui.toast(res.message)
}
}).catch((res) => {})
}
});
}
});
});
},
bigFWHPic(){
uni.previewImage({
urls: [this.FWHPic]
})
},
getCategory(){
let that = this;
this.tui.request("/app/productAttribute/selectAttributeAndValueByCategoryId", "POST", {
categoryId: this.shopList.attrId
}, false, true).then((res1) => {
if (res1.code == 200) {
if (typeof(res1.result.attributeAndValue) == 'string') {
let newObj = JSON.parse(res1.result.attributeAndValue)
let newArr = []
let dataArr = []
for (let val in newObj) {
let valueObj = [];
let isTrue = false
for (var i = 0; i < newObj[val].length; i++) {
for (var m = 0; m < this.oldTemList.length; m++) {
var data = this.oldTemList[m].name.split('/')
for (var j = 0; j < data.length; j++) {
if (data[j] == newObj[val][i]) {
isTrue = true
}
}
}
for (var m = 0; m < this.pageOldTemList.length; m++) {
var data = this.pageOldTemList[m].name.split('/')
for (var j = 0; j < data.length; j++) {
if (data[j] == newObj[val][i]) {
isTrue = true
}
}
}
valueObj.push({
value: newObj[val][i],
isChecked: false
})
that.dataObj.set(newObj[val][i], val)
isTrue = false
}
newArr.push({
name: val,
value: valueObj
})
}
this.shopList.attributeList = newArr;
this.$forceUpdate()
}
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
},
lunbochange(e) {
this.current = e.detail.current
},
checkPay(){
let that = this;
let obj = {
id:this.shopList.categoryId,
// name:this.shopList.categoryName,
userId:this.customId
}
this.tui.request("/app/productShare/save", "POST", {
priceType:this.priceType,
shareType:'1',
scene:JSON.stringify(obj)
}, false, true).then((res) => {
if (res.code == 200) {
uni.navigateTo({
url: '/package1/index/downStearmList?khid=' + res.result.id +'&userId='+this.customId +'&shareType=1'
})
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
},
//弹出购物车或者商品规格选择弹窗
toggle(type, item) {
this.type = type
if (type == 'carPopup') {
this.oldList = this.carList
this.carNum = 0
for (let i = 0; i < this.carList.length; i++) {
this.carNum += this.carList[i].num
}
this.countTotalPrice()
this.$refs.carPopup.open('bottom')
this.carType = this.carList.length
} else {
uni.showLoading({
title: '加载中...'
})
this.productId = item.id
this.goodsList = []
this.allChangeNum = 0
this.checkGoods(item);
}
},
//选择商品查询商品规格
async checkGoods(item) {
uni.showLoading({
title: '加载中...'
})
let that = this;
if (this.priceType == '1') { //批发价
this.purchasePrice = item.wholesalePrice;
} else if(this.priceType == '0'){
this.purchasePrice = item.price;
} else if(this.priceType == '3'){
if(this.shopList.customerCategoryRule != null && this.shopList.customerCategoryRule != ''){
let customerCategoryRule = JSON.parse(this.shopList.customerCategoryRule)
for (var m = 0; m < customerCategoryRule.length; m++) {
if(customerCategoryRule[m].categoryPrice != '' && customerCategoryRule[m].categoryId == this.catagoryUserId){
this.purchasePrice = customerCategoryRule[m].categoryPrice
}
}
}
}
this.goodsDetail = item;
this.temporaryList = []
this.pageOldTemList = []
if (this.carList != '') {
this.zNum = 0
for (let i = 0; i < this.carList.length; i++) {
if (item.id == this.carList[i].id) {
this.goodsNum = this.carList[i].stockLogList1[0].productCount
this.zNum = this.carList[i].num
this.temporaryList = this.carList[i].stockLogList1
this.pageOldTemList = this.carList[i].stockLogList1
this.oldTemList = this.carList[i].stockLogList1
}
}
}
await this.tui.request("/app/productAttribute/selectAttributeAndValueByCategoryId", "POST", {
categoryId: this.goodsDetail.attrId
}, false, true).then((res1) => {
if (res1.code == 200) {
if (typeof(res1.result.attributeAndValue) == 'string') {
let newObj = JSON.parse(res1.result.attributeAndValue)
let newArr = []
let dataArr = []
for (let val in newObj) {
let valueObj = [];
let isTrue = false
for (var i = 0; i < newObj[val].length; i++) {
for (var m = 0; m < this.oldTemList.length; m++) {
var data = this.oldTemList[m].name.split('/')
for (var j = 0; j < data.length; j++) {
if (data[j] == newObj[val][i]) {
isTrue = true
}
}
}
for (var m = 0; m < this.pageOldTemList.length; m++) {
var data = this.pageOldTemList[m].name.split('/')
for (var j = 0; j < data.length; j++) {
if (data[j] == newObj[val][i]) {
isTrue = true
}
}
}
valueObj.push({
value: newObj[val][i],
isChecked: false
})
that.dataObj.set(newObj[val][i], val)
isTrue = false
}
newArr.push({
name: val,
value: valueObj
})
}
this.focus = false
// newArr[0].value[0].isChecked = true
this.$refs.popup.open('bottom')
this.goodsDetail.attributeList = newArr;
for (var i = 0; i < this.goodsDetail.attributeList.length; i++) {
let oldCheck = false
let oldValue = []
for (var m = 0; m < this.goodsDetail.attributeList[i].value.length; m++) {
if (this.goodsDetail.attributeList[i].value[m].isChecked == true) {
oldCheck = true
oldValue.push(this.goodsDetail.attributeList[i].value[m].value)
}
}
if (oldCheck) {
let specs1 = {
specs: []
}
specs1.specs = oldValue
this.goodsList.push(specs1)
} else {
let specs1 = {
specs: []
}
this.goodsList.push(specs1)
}
oldCheck = false
oldValue = []
}
this.getKCList(res1.result.stock);
if (this.temporaryList == '') {
this.attrNameChange(0, this.goodsDetail.attributeList[0].value[0].value, 0)
}
}
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
await uni.hideLoading()
},
//库存商品详情
getKCList(list) {
this.yanseList = new Map()
this.chimaList = new Map()
this.pecsList = list
for (let i = 0; i < list.length; i++) {
let attributeList = JSON.parse(list[i].attributeList)
Object.keys(attributeList).forEach(key => {
if (key == '颜色') {
if (this.yanseList.has(attributeList[key]) != true) {
this.yanseList.set(attributeList[key], attributeList[key])
}
}
})
}
for (let i = 0; i < this.goodsDetail.attributeList[0].value.length; i++) { //颜色
if (this.yanseList.has(this.goodsDetail.attributeList[0].value[i].value) == true) {
this.goodsDetail.attributeList[0].value[i].isKucun = true
}
}
},
goToInfo() {
uni.reLaunch({
url: '/pages/index/home'
})
},
attrNameChange(index, data1,index1) {
uni.showLoading({
title: '加载中...'
})
this.goodsDetail.attributeList[index].isChecked = !this.goodsDetail.attributeList[index].isChecked;
this.goodsDetail.attributeList[index].value[index1].isChecked = !this.goodsDetail.attributeList[index]
.value[index1].isChecked;
this.evalue = []
var value = []
for (let i = 0, data = this.goodsDetail.attributeList[0].value; i < data.length; i++) {
if (data[i].isChecked) {
for (let j = 0, dataJ = this.goodsDetail.attributeList[1].value; j < dataJ.length; j++) {
var name = ''
let value1 = "{"
name = data[i].value + ' | ' + dataJ[j].value
value1 += '"' + '颜色' + '":"' + data[i].value + '",'
value1 += '"' + '尺码' + '":"' + dataJ[j].value + '"'
value1 += "}"
if(this.shopId == '1838094297858183168' || this.shopId == '1811579958284390400'){
for(let a = 0;a<this.pecsList.length;a++){
if(value1 == this.pecsList[a].attributeList && (this.pecsList[a].stockCount != null && Number(this.pecsList[a].stockCount) > 0)){
value.push(value1)
this.evalue.push(name)
}
}
}else{
value.push(value1)
this.evalue.push(name)
}
}
}
}
if (value.length == 0) {
this.temporaryList = this.pageOldTemList
}
if (this.temporaryList.length == 0) {
for (var i = 0; i < value.length; i++) {
this.attributeList = {
attributeList: value[i],
productCount: this.temporaryNum,
productNum: null,
name: this.evalue[i],
price: this.purchasePrice
}
this.temporaryList.push(this.attributeList);
}
} else {
let newProductCount = 0;
for (var i = 0; i < value.length; i++) {
for (var m = 0; m < this.temporaryList.length; m++) {
if (this.temporaryList[m].attributeList == value[i]) {
newProductCount = this.temporaryList[m].productCount
}
}
this.attributeList = {
attributeList: value[i],
productCount: newProductCount,
productNum: null,
name: this.evalue[i],
price: this.purchasePrice
}
this.newTemList.push(this.attributeList);
newProductCount = 0;
}
for (var i = 0; i < this.oldTemList.length; i++) {
let oldAttributeList = '';
let oldProductCount = '';
let notChcek = true;
for (var m = 0; m < this.newTemList.length; m++) {
if (this.oldTemList[i].attributeList == this.newTemList[m].attributeList) {
this.newTemList[m].productCount = this.oldTemList[i].productCount
notChcek = false;
}
}
if (this.newTemList.length > 0 && notChcek) {
this.newTemList.push(this.oldTemList[i]);
}
}
for (var i = 0; i < this.pageOldTemList.length; i++) {
let oldAttributeList = '';
let oldProductCount = '';
let notChcek = true;
for (var m = 0; m < this.newTemList.length; m++) {
if (this.pageOldTemList[i].attributeList == this.newTemList[m].attributeList) {
this.newTemList[m].productCount = this.pageOldTemList[i].productCount
notChcek = false;
}
}
if (this.newTemList.length > 0 && notChcek) {
this.newTemList.push(this.pageOldTemList[i]);
}
}
}
this.$nextTick(() => {
for (var i = 0; i < this.temporaryList.length; i++) {
for (var m = 0; m < this.pecsList.length; m++) {
if (this.temporaryList[i].attributeList == this.pecsList[m].attributeList) {
this.temporaryList[i].productNum = this.pecsList[m].stockCount
}
this.$forceUpdate()
}
}
})
if (this.newTemList.length != 0) {
this.temporaryList = this.newTemList;
this.oldTemList = []
this.newTemList = []
}
setTimeout(res => {
uni.hideLoading();
}, 200)
},
//弹窗选择规格后,点击弹窗中选好了按钮
temporaryCheck() {
let that = this;
let newList = []
for (let i = 0; i < this.temporaryList.length; i++) {
if (this.temporaryList[i].productCount != 0) {
newList.push(this.temporaryList[i])
}
}
let data = {
productId: this.goodsDetail.id,
price: this.zPrice,
num: this.zNum,
discount:10,
categoryId:this.goodsDetail.categoryId,
productName: this.goodsDetail.productName,
purchasePrice: this.goodsDetail.purchasePrice,
discountAmount: this.goodsDetail.discountAmount,
productSn: this.goodsDetail.productSn,
productPicture: this.goodsDetail.productPicture,
supplierName: this.goodsDetail.supplierName,
stockLogList1: newList,
saleDetailQueryDTO1: [],
wholesalePrice: this.goodsDetail.wholesalePrice,
lsprice: this.goodsDetail.price
}
if (this.carList.length == 0) {
this.carList.push(data)
} else {
let aa = true;
for (let i = 0; i < this.carList.length; i++) {
if (this.carList[i].productId == data.productId) {
this.carList[i] = data
aa = false
}
}
if (aa) {
this.carList.push(data)
}
}
for (let i = 0; i < this.carList.length; i++) {
this.carList[i].num = 0
for (let m = 0; m < this.carList[i].stockLogList1.length; m++) {
this.carList[i].num += this.carList[i].stockLogList1[m].productCount
}
}
this.temporaryList = []
this.oldTemList = []
this.purchasePrice = ''
this.zPrice = ''
this.zNum = ''
for (let i = 0; i < this.goodsDetail.attributeList.length; i++) {
this.goodsDetail.attributeList[i].isChecked = false;
for (let m = 0; m < this.goodsDetail.attributeList[i].value.length; m++) {
this.goodsDetail.attributeList[i].value[m].isChecked = false
}
}
this.$refs.popup.close()
this.clickPrice()
},
checkUser(item){
this.formData.consigneeMobile = item.phone
this.formData.consigneeName = item.name
this.formData.userId = item.id
this.formData.address1 = item.province + item.city + item.area
this.formData.address = item.address
this.formData.province = item.province
this.formData.city = item.city
this.formData.area = item.area
this.$refs.addressPopup.close()
},
//选商品的时候能删除规格
delCarData(index) {
this.temporaryList.splice(index, 1);
this.temporaryChange()
},
//点击底部下单按钮
backPrevPage() {
if(this.isKaiDan)return
this.isKaiDan = true
if(this.carList[0].stockLogList1.length < 1){
this.tui.toast('请选择商品后再开单')
return
}
let that = this;
uni.setStorageSync('userPhone',that.formData.consigneeMobile)
this.$refs.form.validate().then(res => {
let obj = {
mobile: that.formData.consigneeMobile,
username: that.formData.consigneeName,
userId:(this.formData.userId == undefined || this.formData.userId == null || this.formData.userId == 'undefined' || this.formData.userId == 'null')? '' : this.formData.userId,
categoryId:(this.priceType == "1" || this.priceType == '0')?'':this.catagoryUserId,
categoryName:(this.priceType == "1" || this.priceType == '0')?'':this.customName,
oldSaleId: this.khid,
sale: {
area: this.formData.area,
city: this.formData.city,
discount:10,
province: this.formData.province,
receiveAddress: that.formData.address,
totalAmount: that.pageZongPrice, //应付金额
shopId: this.shopId,
},
saleDetailList: this.carList
}
this.tui.request("/app/sale/savePresale", "post", obj, false, false).then((res) => {
if (res.code == 200) {
this.tui.toast("下单成功,待商家配货")
setTimeout(() => {
uni.reLaunch({
url: `/package2/login/login`
})
}, 2000)
} else {
this.tui.toast(res.message)
}
})
}).catch(err => {
})
},
openPicker() {
let that = this;
uni.chooseLocation({
success: function(res) {
if (res.name != '') {
let aaa = getArea(res.address)
that.formData.province = aaa.province
that.formData.city = aaa.city
that.formData.area = aaa.country
that.formData.address = aaa.address + '-' + res.name
that.formData.address1 = aaa.province + aaa.city + aaa.country
} else {
that.tui.toast("微信地址选择器调用失败,请重新选择!")
}
},
fail: function(res) {
}
});
// this.show = true
},
//保存已选
saveCheck(){
this.pageOldTemList = this.temporaryList
for(var i=0;i<this.goodsDetail.attributeList.length;i++){
this.goodsList[i].specs = []
for(var m=0;m<this.goodsDetail.attributeList[i].value.length;m++){
this.goodsDetail.attributeList[i].value[m].isChecked = false
}
}
},
minusNum(){
this.isChange = true
for (var i = 0; i < this.temporaryList.length; i++) {
if (this.evalue.length == 0) {
if(this.temporaryList[i].productCount > 0){
this.temporaryList[i].productCount--
}else{
this.temporaryList[i].productCount = 0
}
} else {
for (var j = 0; j < this.evalue.length; j++) {
if (this.evalue[j] == this.temporaryList[i].name) {
if(this.temporaryList[i].productCount > 0){
this.temporaryList[i].productCount--
}else{
this.temporaryList[i].productCount = 0
}
}
}
}
for (var m = 0; m < this.pageOldTemList.length; m++) {
if (this.temporaryList[i].attributeList == this.pageOldTemList[m].attributeList) {
this.pageOldTemList[m].productCount = this.temporaryList[i].productCount
}
}
for (var j = 0; j < this.oldTemList.length; j++) {
if (this.temporaryList[i].attributeList == this.oldTemList[j].attributeList) {
this.oldTemList[j].productCount = this.temporaryList[i].productCount
}
}
}
this.temporaryChange()
},
plusNum(){
this.isChange = true
//监听到点击+的操作,给所有的都+1
for (var i = 0; i < this.temporaryList.length; i++) {
if (this.evalue.length == 0) {
if (this.temporaryList[i].productCount == undefined) {
this.temporaryList[i].productCount = 1
} else {
if(this.temporaryList[i].productCount + 1 > this.temporaryList[i].productNum && (this.shopId == '1838094297858183168' || this.shopId == '1811579958284390400')){
this.tui.toast(this.temporaryList[i].name + "已超出可购买数量",300)
}else{
this.temporaryList[i].productCount++
}
}
} else {
for (var j = 0; j < this.evalue.length; j++) {
if (this.evalue[j] == this.temporaryList[i].name) {
if (this.temporaryList[i].productCount == undefined) {
this.temporaryList[i].productCount = 1
} else {
if(this.temporaryList[i].productCount + 1 > this.temporaryList[i].productNum && (this.shopId == '1838094297858183168' || this.shopId == '1811579958284390400')){
this.tui.toast(this.temporaryList[i].name + "已超出可购买数量",300)
}else{
this.temporaryList[i].productCount++
}
}
}
}
}
for (var m = 0; m < this.pageOldTemList.length; m++) {
if (this.temporaryList[i].attributeList == this.pageOldTemList[m].attributeList) {
this.pageOldTemList[m].productCount = this.temporaryList[i].productCount
}
}
for (var j = 0; j < this.oldTemList.length; j++) {
if (this.temporaryList[i].attributeList == this.oldTemList[j].attributeList) {
this.oldTemList[j].productCount = this.temporaryList[i].productCount
}
}
}
this.temporaryChange()
},
allChange(e){
if(this.isChange == true){
this.isChange = false
}else{
for (var i = 0; i < this.temporaryList.length; i++) {
if (this.evalue.length == 0) {
if(Number(this.allChangeNum) > this.temporaryList[i].productNum && (this.shopId == '1838094297858183168' || this.shopId == '1811579958284390400')){
this.tui.toast(this.temporaryList[i].name + "已超出可购买数量",300)
}else{
this.temporaryList[i].productCount = Number(this.allChangeNum)
}
} else {
for (var j = 0; j < this.evalue.length; j++) {
if (this.evalue[j] == this.temporaryList[i].name) {
if(Number(this.allChangeNum) > this.temporaryList[i].productNum && (this.shopId == '1838094297858183168' || this.shopId == '1811579958284390400')){
this.tui.toast(this.temporaryList[i].name + "已超出可购买数量",300)
}else{
this.temporaryList[i].productCount = Number(this.allChangeNum)
}
}
}
}
for (var m = 0; m < this.pageOldTemList.length; m++) {
if (this.temporaryList[i].attributeList == this.pageOldTemList[m].attributeList) {
this.pageOldTemList[m].productCount = this.temporaryList[i].productCount
}
}
for (var j = 0; j < this.oldTemList.length; j++) {
if (this.temporaryList[i].attributeList == this.oldTemList[j].attributeList) {
this.oldTemList[j].productCount = this.temporaryList[i].productCount
}
}
}
}
this.temporaryChange()
},
temporaryChange(val) {
this.zNum = 0
for (var i = 0; i < this.temporaryList.length; i++) {
this.zNum += this.temporaryList[i].productCount || 0
}
this.zPrice = this.zNum * this.purchasePrice
},
//点击开单按钮,调起地址输入窗
clickPrice() {
if(this.carList[0].stockLogList1.length < 1){
this.tui.toast('请选择商品后再开单')
return
}
this.getOldPhone(uni.getStorageSync('id')?uni.getStorageSync('id'):this.userId)
this.$refs.inputDialog.open('bottom')
},
getOldPhone(phone){
let moblie
if(phone != '' && phone != undefined && phone != 'null' && phone != null){
moblie = phone
}else if(uni.getStorageSync('userPhone')){
moblie = uni.getStorageSync('userPhone')
}else{
moblie = ""
}
this.tui.request("/app/customer/findByUserPhoneAndShopId", "post", {
userPhone:moblie,
shopId:this.shopId
}, false, true).then((res) => {
if (res.code == 200) {
if(res.result != ''){
if(res.result.length > 1){
this.userList = res.result
this.$refs.addressPopup.open()
}else{
this.formData.consigneeMobile = res.result[0].phone
this.formData.consigneeName = res.result[0].name
this.formData.address1 = res.result[0].province + res.result[0].city + res.result[0].area
this.formData.address = res.result[0].address
this.formData.userId = res.result[0].id
this.formData.province = res.result[0].province
this.formData.city = res.result[0].city
this.formData.area = res.result[0].area
}
}
}
})
},
}
}
</script>
<style lang="scss">
page {
height: 100%;
}
.page1 {
flex-direction: column;
height: 100%;
}
.title{
height: 500rpx;
}
.swiper-box {
height: 500rpx;
}
.swiper-item {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 1000rpx;
color: #fff;
background-color: #cee1fd;
border-radius: 10px;
}
.popup-content {
align-items: center;
justify-content: center;
padding: 15px;
height: 1200rpx;
background-color: #fff;
margin-bottom: 80rpx;
overflow: scroll;
}
.popup-title-right-box {
height: 50rpx;
line-height: 50rpx;
}
.popup-title-right {
width: 400rpx;
margin-left: 30rpx;
}
.popup-title-left {
width: 150rpx;
height: 150rpx;
}
.popup-title-left image {
width: 150rpx;
height: 150rpx;
}
.popup-title {
display: flex;
height: 180rpx;
border-bottom: 1px solid #eee;
margin-top: 20rpx;
}
.popup-container {
width: 100%;
background: #fff;
height: 50rpx;
}
.title-fur {
width: 95%;
height: 50rpx;
margin: 0 auto;
}
.name {
font-size: 30rpx;
width: 50%;
float: left;
height: 50rpx;
line-height: 70rpx;
}
.checkList {
display: flex;
height: 50rpx;
font-size: 28rpx;
line-height: 50rpx;
margin: 20rpx 0;
}
.checkList-box {
height: 50rpx;
width: 60%;
}
.popup-bottom {
width: 95%;
height: 100rpx;
position: fixed;
bottom: 0;
left: 2.5%;
display: flex;
z-index: 99;
background: #fff;
}
.popup-bottom-left {
width: 50%;
line-height: 80rpx;
}
.popup-bottom-right {
width: 50%;
line-height: 100rpx;
.bottom-btn {
width: 70%;
line-height: 35px;
height: 70rpx;
text-align: center;
/* margin-top: 10rpx; */
color: #fff;
font-size: 28rpx;
margin: 0 auto;
background: linear-gradient(90deg, #60F3FF, #088FEB);
border-radius: 70rpx;
}
}
.attrs {
.suibian {
display: inline-block;
border: 1px solid #5fd9ee;
margin: 20rpx;
margin-bottom: 0;
margin-left: 0;
background-color: #fff;
color: #5fd9ee;
padding: 0 10px;
min-width: 100rpx;
line-height: 35px;
height: 70rpx;
text-align: center;
border-radius: 20rpx;
}
.checkedText {
background-color: #5fd9ee;
color: #fff;
border-radius: 20rpx;
}
}
.kucun{
background: url(https://jewel-shop.oss-cn-beijing.aliyuncs.com/9428d632981647728829da336a1d24b3.png) no-repeat;
width: 50rpx;
height: 25rpx;
position: absolute;
top: -14rpx;
right: -15rpx;
background-size: 100%;
}
.img-popup-content {
width: 500rpx;
height: 500rpx;
}
.popup-pay-title {
height: 100rpx;
line-height: 100rpx;
text-align: center;
font-weight: bold;
font-size: 32rpx;
}
.popup-pay-content {
align-items: center;
justify-content: center;
padding: 0 15px 15px 15px;
width: 95%;
margin: 0 auto;
height: auto;
background-color: #fff;
}
.address-btn {
width: 100%;
height: 80rpx;
background: #088FEB;
color: #fff;
font-size: 36rpx;
text-align: center;
line-height: 80rpx;
border-radius: 10px;
}
</style>