Merge branch 'main' into prod

This commit is contained in:
weipengfei 2023-11-29 18:42:37 +08:00
commit 6c54f05221
19 changed files with 1460 additions and 231 deletions

56
App.vue
View File

@ -20,6 +20,9 @@
getUserInfo
} from '@/api/user.js';
import {
parseToken
} from "@/api/appLet.js";
import {
HTTP_REQUEST_URL
} from './config/app';
@ -29,6 +32,7 @@
history
} from '@/api/public.js'
import Routine from './libs/routine.js';
import { Toast } from "./libs/uniApi";
export default {
data() {
@ -93,16 +97,52 @@
key: 'launchFlag'
})
//
// parseToken({
// token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJjZXNoaS1taWRkbGUubGloYWluay5jbiIsImF1ZCI6ImNlc2hpLW1pZGRsZS5saWhhaW5rLmNuIiwiaWF0IjoxNzAwNjIwMjUxLCJuYmYiOjE3MDA2MjAyNTEsImV4cCI6MTcwMTIyNTA1MSwiZGF0YSI6eyJ1aWQiOjUsInBob25lIjoiMTc2ODUxNTE2NDMiLCJhdmF0YXIiOiIvcmVzb3VyY2UvaW1hZ2UvYWRtaW5hcGkvZGVmYXVsdC9kZWZhdWx0X2F2YXRhci5wbmciLCJuaWNrbmFtZSI6Ilx1NzUyOFx1NjIzNzE3Njg1MTUxNjQzIn19.sTWAHCScRY9FExwJw1MReHTnRBcK7tYu1AMSia_Sm4M'
// }).then((res)=>{
// this.$store.commit("LOGIN", {
// 'token': res.data.token,
// 'time': 604800
// });
// this.$isResolve()
// }).catch((err)=>{
// if(err==''){
// this.$store.commit("LOGIN", {
// 'token': option.referrerInfo?.extraData?.uniMP,
// 'time': 604800
// });
// }else {
// Toast(err);
// }
// this.$isResolve()
// })
if (option.referrerInfo?.extraData?.uniMP) {
if (option?.referrerInfo?.extraData?.uniMP) {
uni.setStorageSync('uniMP', option.referrerInfo?.extraData?.uniMP);
// uni.setStorageSync('APP_token', option.referrerInfo?.extraData?.token);
this.$store.commit("LOGIN", {
'token': option.referrerInfo?.extraData?.token,
'time': 604800
});
}
// this.$store.commit("LOGIN", {
// 'token': option.referrerInfo?.extraData?.token,
// 'time': 604800
// });
parseToken({
token: option.referrerInfo?.extraData?.token
}).then((res)=>{
this.$store.commit("LOGIN", {
'token': res.data.token,
'time': 604800
});
this.$isResolve()
}).catch((err)=>{
this.$store.commit("LOGIN", {
'token': option.referrerInfo?.extraData?.token,
'time': 604800
});
console.log('TOKEN解析错误:', err);
this.$isResolve()
})
}else {
this.$isResolve()
}
// #ifdef APP-PLUS
// #endif

9
api/appLet.js Normal file
View File

@ -0,0 +1,9 @@
import request from "@/utils/request.js";
/**
* 文章详情
*
*/
export function parseToken(data) {
return request.post('parse/token', data, { noAuth: true });
}

View File

@ -23,3 +23,7 @@ export function getCartList(data) {
export function getCartCounts(data) {
return request.get("user/cart/count", data);
}
export function getCategoryListLevel(data) {
return request.get("category/list_level", data);
}

View File

@ -34,6 +34,12 @@ Vue.prototype.$eventHub = new Vue();
Vue.config.productionTip = false
Vue.prototype.$bus = new Vue();
// initRouter()
// 让app的onLaunch先执行主要是用来进行登录
Vue.prototype.$onLaunched = new Promise(resolve => {
Vue.prototype.$isResolve = resolve
})
// #ifdef H5
import {
parseQuery

View File

@ -1332,7 +1332,15 @@
"path" : "addGood/addGood",
"style" :
{
"navigationBarTitleText" : "",
"navigationBarTitleText" : "商品设置",
"enablePullDownRefresh" : false
}
},
{
"path" : "addGood/specGood",
"style" :
{
"navigationBarTitleText" : "规格设置",
"enablePullDownRefresh" : false
}
},

View File

@ -1,5 +1,5 @@
<template>
<view>
<view style="padding-bottom: 30rpx;">
<view class="order-index" ref="container">
<view class="header acea-row">
<navigator class="item" :url="`/pages/admin/orderList/index?types=1&merId=${mer_id}`"
@ -83,8 +83,8 @@
<view class="item acea-row row-between-wrapper" v-for="(item, index) in list" :key="index">
<view class="data">{{ item.day }}</view>
<view class="browse">{{ item.total }}</view>
<view class="turnover">{{ item.pay_price }}</view>
<view class="turnover">{{ item.pay_price }}</view>
<view class="turnover" @click="navToOrder(item, 2)">{{ item.pay_price }}</view>
<view class="turnover" @click="navToOrder(item, 4)">{{ toFixed2(item.settlement_price) }}</view>
</view>
</view>
</view>
@ -270,7 +270,21 @@
this.OrderList = res.data
// console.log(this.OrderList);
})
}
},
//
toFixed2(num){
let str = num;
if(typeof num =='string'){
str = +str;
str = str.toFixed(2);
}else str = str.toFixed(2);
return str || '0.00';
},
navToOrder(item, type=2){
uni.navigateTo({
url: `/pages/admin/orderList/index?merId=${this.mer_id}&types=${type}&pay_time=${item.pay_time.split(' ')[0]}`
})
}
},
onReachBottom() {
this.getList(this.mer_id)

View File

@ -50,7 +50,7 @@
<view v-if="val.product" class="goods acea-row row-between-wrapper">
<view class="picTxt acea-row row-between-wrapper">
<view class="pictrue">
<image :src="val.product.cart_info.product.image" />
<image :src="val.product.cart_info.productAttr.image||val.product.cart_info.product.image" />
</view>
<view class="text acea-row row-between row-column">
<view class="info line1 refund-info">
@ -74,6 +74,7 @@
<text v-if="item.status == 0" class="iconfont icon-tuikuanzhong on"></text>
<text v-if="item.status == 1 || item.status == 2" class="iconfont icon-tuihuozhong on"></text>
<text v-if="item.status == 3" class="iconfont icon-yituikuan1"></text>
<text v-if="item.status == -2" class="iconfont icon-yiquxiao"></text>
</view>
<view class="operation acea-row row-between-wrapper">
<view class="more">
@ -109,7 +110,7 @@
<view class="acea-row row-between-wrapper">
<view class="picTxt acea-row row-between-wrapper">
<view class="pictrue">
<image :src="val.cart_info.product.image" />
<image :src="val.cart_info.productAttr.image||val.cart_info.product.image" />
</view>
<view class="text acea-row row-between row-column">
<view class="info line2">
@ -262,7 +263,8 @@
limit: 10,
status: 1,
search_info: '',
product_type: ''
product_type: '',
pay_time: null,
},
list: [],
loaded: false,
@ -291,6 +293,9 @@
this.where.status = option.types
this.current = "";
this.merId = option.merId;
if(option.pay_time){
this.where.pay_time = option.pay_time;
}
this.getIndex();
},
@ -332,7 +337,7 @@
let that = this;
console.log(that.merId)
// console.log(that.merId)
if (that.loading || that.loaded) return;
that.loading = true;
if (that.where.status == 6) {

View File

@ -208,7 +208,8 @@
</script>
<style lang="scss">
.refund-wrapper{
.refund-wrapper{
padding-bottom: 150rpx;
.form-box{
padding-left: 30rpx;
margin-top: 18rpx;

View File

@ -121,7 +121,15 @@
getUserInfo().then(res => {
if (res.data.mer_info.length == 0) {
return uni.showModal({
title: '暂无商户信息'
title: '暂无商户信息',
complete(res) {
// #ifdef APP-PLUS
uni.sendHostEvent('closeApp', (ret) => {
//
console.log('关闭应用' + JSON.stringify(ret));
});
// #endif
}
})
}
this.mer_id = res.data.service.mer_id;

View File

@ -131,8 +131,8 @@
<view class="list-one_right-b">待发货</view>
</view>
</view>
<view class="" v-for="(g,h) in item.orderProduct">
<view class="list-two">
<view class="">
<view class="list-two" v-for="(g,h) in item.orderProduct">
<view class="list-two_left">
<image :src="g.cart_info.product.image" mode=""></image>
</view>
@ -563,13 +563,16 @@
}
},
onPullDownRefresh() {
this.getGoods(true)
uni.stopPullDownRefresh()
this.getGoods(true).then(()=>{
uni.stopPullDownRefresh()
})
},
onLoad() {
this.list1()
async onLoad() {
this.Fheight = uni.getSystemInfoSync().windowHeight + 'px';
await this.$onLaunched;
this.list1()
},
@ -579,13 +582,15 @@
if (this.productList.length > 0) {
setTimeout(() => {
this.getGoods(false);
}, 1000)
this.getindex();
}, 10)
}
},
onShow() {
async onShow() {
await this.$onLaunched;
this.getUserInfo()
this.codelist()
},
@ -955,13 +960,20 @@
}
if (res.data.mer_info.length == 0) {
uni.showModal({
title: '暂无商户信息'
title: '暂无商户信息',
complete(res) {
// #ifdef APP-PLUS
uni.sendHostEvent('closeApp', (ret) => {
//
console.log('关闭应用' + JSON.stringify(ret));
});
// #endif
}
})
} else {
this.getindex()
this.getGoods(true)
}
merstreet({
street_code: res.data.mer_info.street_id
}).then((res) => {
@ -974,7 +986,7 @@
this.company = res.data.title
this.organization_code = res.data.organization_code
}).catch(res => {
console.log(res)
console.log('错误:', res)
})
});
},
@ -1149,16 +1161,19 @@
},
//
getGoods: function(isPage) {
getGoods: async function(isPage) {
let that = this;
if (that.loadend) return;
if (that.loading) return;
if (isPage === true) that.$set(that, 'productList', []);
if (isPage === true) {
that.where.page = 1;
that.$set(that, 'productList', []);
}
that.loading = true;
that.loadTitle = '';
getOrderList(that.where, this.userInfoData.service.mer_id).then(res => {
await getOrderList(that.where, this.userInfoData.service.mer_id).then(res => {
let list = res.data.list;
let productList = that.$util.SplitArray(list, that.productList);
let loadend = list.length < that.where.limit;

View File

@ -237,27 +237,28 @@
editGoodsStore: '',
editGoodsShow: false, //
mer_id: 0,
userInfo: {},
searchGoodsShow: false,
searchGoodsName: '',
showModel: false,
showModelCode: '',
goods: [
// {
// "id": 7,
// "store_name": " 400",
// "bar_code": "6922868290895",
// {
// "id": 314,
// "store_name": "",
// "bar_code": "6974008060011",
// "manu_address": "",
// "price": "4.80",
// "price": "0.00",
// "stock": 9999999,
// "image": "http://lihai001.oss-cn-chengdu.aliyuncs.com/def/2023-11-02/202311021740247976.jpg",
// "image": "http://lihai001.oss-cn-chengdu.aliyuncs.com/def/2023-11-18/202311181017131387.jpg",
// "slider_image": [
// "https://lihai001.oss-cn-chengdu.aliyuncs.com/def/e4784202311041417185146.jpg"
// "http://lihai001.oss-cn-chengdu.aliyuncs.com/def/2023-11-18/202311181017131387.jpg"
// ],
// "spec": "****()",
// "trademark": "****()",
// "spec": "560",
// "trademark": "",
// "manu_name": null,
// "note": "login_dateJul 13 1998 12:00:00:000AMvalid_dateJul 13 2020 12:00:00:000AM"
// },
// "note": ""
// }
],
putGoods: { //
@ -283,17 +284,20 @@
},
onLoad(e) {
this.mer_id = e.mer_id
this.userInfo = this.$store.state.app.userInfo;
if(typeof this.userInfo == 'string') this.userInfo = JSON.parse(this.userInfo);
},
onShow() {
},
methods: {
addGoods(item) {
if(this.isNullImage(item.image)||
( this.isNullImage(item.slider_image[0]) && this.isNullImage(item.slider_image[1]) && this.isNullImage(item.slider_image[2]) )){
return Toast('请先上传商品图片后再加入店铺');
}
if(item.update) return Toast('请保存修改后再添加');
addGoods(item={}) {
item = JSON.parse(JSON.stringify(item));
// if(this.isNullImage(item.image)||
// ( this.isNullImage(item.slider_image[0]) && this.isNullImage(item.slider_image[1]) && this.isNullImage(item.slider_image[2]) )){
// return Toast('');
// }
// if(item.update) return Toast('');
this.putGoods.id = item.id;
this.putGoods.price = '';
this.putGoods.stock = '';
@ -308,9 +312,50 @@
this.putGoods[key] = item[key];
}
})
this.addGoodsShow = true
this.item = item
this.initShop(item);
// this.addGoodsShow = true
// this.item = item
},
initShop(item){
item.attr = [{
value: '规格',
detail: [item.spec]
}]
item.attrValue = [{
"detail": {
'规格': item.spec
},
"sku": item.spec,
"stock": 0,
"image": item.image,
"bar_code": item.bar_code,
"cost": "",
"ot_price": "",
"price": item.price,
"volume": "",
"weight": "",
}]
item.spec_type = 1;
item.import_id = item.id + '';
item.imageList = [item.image, ...item.slider_image];
item.content = {
title: '',
image: item.slider_image[0]?[item.slider_image[0]]:[]
}
delete item.id;
delete item.stock;
console.log({...item});
uni.navigateTo({
url: `/pages/product/addGood/addGood?mer_id=${this.userInfo.service.mer_id}&import=1`,
success: (e) => {
e.eventChannel.emit('importAttrValue', item);
uni.$once('importAttrValueOK', (e)=>{
this.goods = this.goods.filter(t=>{
return t.id!=e;
})
})
}
})
},
isNullImage(src){
let flag = false;
@ -528,7 +573,7 @@
Toast("暂无搜索商品,请添加!")
setTimeout(() => {
uni.navigateTo({
url: `/pages/product/addGoods/index?mer_id=${rq.mer_id}`
url: `/pages/product/addGood/addGood?mer_id=${rq.mer_id}`
})
}, 2000)
return
@ -646,8 +691,8 @@
},
navToAdd(){
let url;
if(this.showModelCode) url = `/pages/product/addGoods/index?mer_id=${this.mer_id}&code=${this.showModelCode}`;
else url = `/pages/product/addGoods/index?mer_id=${this.mer_id}`;
if(this.showModelCode) url = `/pages/product/addGood/addGood?mer_id=${this.mer_id}&code=${this.showModelCode}`;
else url = `/pages/product/addGood/addGood?mer_id=${this.mer_id}`;
uni.navigateTo({
url:url,
success:()=> {
@ -667,7 +712,7 @@
}
})
}
navigateTo(1, '/pages/product/addGoods/index', {
navigateTo(1, '/pages/product/addGood/addGood', {
mer_id: this.mer_id
});
},

View File

@ -35,15 +35,15 @@
</view>
</view>
</view>
<u-popup ref="select_popup" class="pop" :show="show" mode="center" closeOnClickOverlay bgColor='transparent'>
<image :src="image"></image>
<image src="@/static/images/guanbi.png" class="guanbi" @click="close"></image>
</u-popup>
<u-popup ref="select_popup" class="pop" :show="show" mode="center" closeOnClickOverlay bgColor='transparent'>
<image :src="image"></image>
<image src="@/static/images/guanbi.png" class="guanbi" @click="close"></image>
</u-popup>
</view>
<!-- 商品详情 -->
<commodityComponent v-if="showCommodity" :key="showCommodity" :showCommodity="showCommodity" :product_id="product_id" :merId="merId"
:code="code" @lastStep="lastStep">
<commodityComponent ref="commodityRef" v-if="showCommodity" :key="showCommodity" :showCommodity="showCommodity"
:product_id="product_id" :merId="merId" :code="code">
</commodityComponent>
<view class="popup_group">
@ -58,32 +58,61 @@
<view><span class="iconfont">&#xe6bd;</span></view>
</view>
</view>
<view class="popup_group_item">
<view class="popup_group_item_label">商品单位</view>
<view class="popup_group_item_value"><input v-model="setFormData.unit_name" type="text"
placeholder="请填写商品单位" /></view>
</view>
</view>
<!-- 选择平台分类弹框 -->
<uni-popup ref="select_platform" type="bottom">
<platfrom @close="closePlatfrom" :classifiedData="platformClassificationData" @getPlatData="getPlatData">
</platfrom>
</uni-popup>
<!-- 规格设置 -->
<priceComponent :product_id="product_id" :bar_code="code" @updateCode = "updateCode" v-if="showCommodity"></priceComponent>
<!-- 规格设置 -->
<picker mode="selector" :range="['单规格','多规格']" :value="setFormData.spec_type" @change="changeSpecType">
<view class="popup_group" style="margin-bottom: 0;">
<view class="popup_group_item">
<view class="popup_group_item_label">商品规格</view>
<view class="popup_group_item_value">
<view class="popup_group_item_message">
<span class="popup_group_item_message_value">{{ setFormData.spec_type==0?'单规格':'多规格' }}</span>
</view>
<view><span class="iconfont">&#xe6bd;</span></view>
</view>
</view>
</view>
<u-modal :show="showSpecType" title="温馨提示" content="切换后商品原有规格将失效,是否继续?"
show-cancel-button confirm-text="继续" @confirm="changeSpecType2" @cancel="showSpecType=false"
></u-modal>
</picker>
<priceComponent v-if="setFormData.spec_type==0" :datas="setFormData.attrValue[0]" ref="priceRef" :product_id="product_id" :bar_code="code" @updateCode="updateCode">
</priceComponent>
<view v-else class="popup_group" style="margin-top: 0;border-top: 1rpx solid #eeeeee;">
<view class="popup_group_item" @click="navToSpecGood()">
<view class="popup_group_item_label" style="flex: 1; text-align: center;">
设置多规格
<text v-if="setFormData.attrValue.length>0">({{setFormData.attrValue.length}})</text>
</view>
</view>
</view>
<view class="popup_group">
<!-- <view class="popup_group_item" @click="showMoreInfo=!showMoreInfo">
<!-- <view class="popup_group_item" @click="showMoreInfo=!showMoreInfo">
<view class="popup_group_item_label">更多信息</view>
<view class="popup_group_item_value" :class="showMoreInfo?'icon_bottom':'icon_top'">
<view><span class="iconfont">&#xe6bd;</span></view>
</view>
</view> -->
<block >
<block>
<view class="input_content">
<!-- <view class="input_content_describe" style="border-top: none">
<view class="input_content_describe_title">
@ -99,7 +128,7 @@
placeholderClass="placeholderClass" maxlength="200" />
</view>
</view> -->
<view class="input_content_keyword">
<view class="input_content_keyword_label">关键字</view>
<view class="input_content_keyword_value"><input v-model="setFormData.keyword" type="text" value=""
@ -108,7 +137,7 @@
</view>
<view class="radio">
<view class="radio_label ">送货方式</view>
<checkbox-group class="select_group flex_start" @change="deliveryWayChange">
<checkbox-group class="select_group flex_start">
<label class="radio_select" v-for="(val, i) in deliveryFreeList" :key="val.value">
<view>
<checkbox :value="val.value" disabled :checked="val.value" />
@ -118,25 +147,20 @@
</checkbox-group>
</view>
</block>
</view>
</view>
<view class="handle">
<view class="handle_button" @click="submitCreatedGoods">提交</view>
</view>
<uni-popup ref="tempId" type="bottom">
<linkage-assembly selectProductTitle="选择运费模板" :form="setFormData" :classifiedData="classified['temp_id']"
:selectProductItem="productItem" :mer_id="merId" @getLinkageData="getTempIdData" @multipleList="multipleList"
@close="$refs.tempId.close()" @scrolltolower="scrolltolower"></linkage-assembly>
</uni-popup>
<!-- 图片选择器 -->
<avatar @upload="doUpload" @getName="getImgName" quality="1" ref="avatar" selWidth="250upx" selHeight="250upx">
</avatar>
</view>
</template>
@ -153,14 +177,23 @@
attrList,
templateList,
productDetail,
getDeliveryType
getDeliveryType,
productCreate,
productUpdate
} from '@/api/product.js';
import {
serialize,
Toast,
Loading,
hideLoading,
Modal
} from "@/libs/uniApi.js";
import avatar from "@/components/yq-avatar/yq-avatar.vue";
import platfrom from "./components/platform.vue";
import commodityComponent from "./components/commodity.vue";
import priceComponent from "./components/price.vue";
export default {
components:{
components: {
avatar,
platfrom,
commodityComponent,
@ -171,14 +204,28 @@
bar_code_dis: false,
merId: '', //id
product_id: '', //id
import: 0, //
code: '', //
show: false, //
image: false, //
setFormData:{
setFormData: {
store_name: '',
imageList: [],
cate_name: '', //
attrValue: [],
cate_name: '', //
unit_name: '', //
cate_id: '', // id
mer_cate_id: '', //
mer_cate_name: '', //
spec_type: '0', // 0. 1
attr: [], //
specifica: '', //
// setSpecificaValue: '', //
// setSpecificaValue2: '',
delivery_way: [1, 2], // 1 2
delivery_free: '1', // 0 1
temp_id: '', // ID
tempName: '' //
},
platformClassificationData: [], //
merchantClassification: [], //
@ -202,29 +249,102 @@
temp_id: []
},
productItem: {} || [],
showSpecType: false, //
spec_type: 0, //,0,1
};
},
onLoad(opt) {
this.merId = Number(opt.mer_id);
this.product_id = opt.product_id;
if(!opt.product_id)this.showCommodity=true;
this.import = opt.import;
// if (!opt.product_id) this.showCommodity = true;
this.showCommodity = true;;
this.initData();
this.initClasiffy();
if(this.import==1){
this.getOpenerEventChannel().once('importAttrValue', (e) => {
this.attrValue = e.attrValue;
uni.setStorageSync('attrValue', JSON.stringify(e.attrValue));
this.attr = e.attr;
uni.setStorageSync('attr', JSON.stringify(e.attr));
this.setFormData = Object.assign({}, this.setFormData, e);
this.$nextTick(()=>{
this.$refs.commodityRef?.setDatas({
addGoodsSecoundData: {
is_good: this.setFormData.is_good, //
is_gift_bag: this.setFormData.is_gift_bag,
sort: this.setFormData.sort,
once_count: this.setFormData.once_count, //
video_link: this.setFormData.video_link,
},
goodsDis: {
store_name: this.setFormData.content?.title,
imageList: this.setFormData.content?.image
}
})
})
})
}
else if(this.product_id){
this.initDataEditData();
}
},
onBackPress() {
},
onBackPress() {},
onShow() {
// this.setFormData = Object.assign(this.setFormData, {
// "store_name": "",
// "imageList": [
// "https://lihai001.oss-cn-chengdu.aliyuncs.com/def/457c6202311181745387896.jpeg",
// "https://lihai001.oss-cn-chengdu.aliyuncs.com/def/185e2202311181745434402.jpeg"
// ],
// "cate_name": "",
// "unit_name": "",
// "cate_id": 445,
// "keyword": "22"
// })
// this.$nextTick(async () => {
// await this.$u.sleep(200)
// this.$refs.commodityRef.addGoodsSecoundData = {
// "is_good": 1,
// "is_gift_bag": 0,
// "sort": "20",
// "once_count": "",
// "video_link": "https://lihai001.oss-cn-chengdu.aliyuncs.com/media/7ce3d202311181816166215.mp4"
// }
// this.$refs.commodityRef.goodsDis = {
// "store_name": "",
// "imageList": [
// "https://lihai001.oss-cn-chengdu.aliyuncs.com/def/fb73d202311181751262661.png"
// ]
// }
// this.$refs.priceRef.singleSpecification = {
// "price": "1",
// "cost": "1",
// "stock": "11",
// "ot_price": "",
// "procure_price": "",
// "bar_code": "666",
// "weight": "10",
// "volume": "5",
// "image": "",
// "extension_one": "",
// "extension_two": ""
// }
// })
},
beforeDestroy() {
beforeDestroy() {},
watch: {
'setFormData.imageList'(val) {
this.setFormData.image = val.length ? val[0] : '';
this.setFormData.slider_image = val.length ? serialize(val).splice(1) : [];
}
},
methods: {
//
initDataEditData() {
this.setFormData = {
imageList: [],
attrValue: [],
specification: '',
image: '', //
slider_image: '', //
@ -241,20 +361,16 @@
spec_type: '0', // 0. 1
attr: [], //
specifica: '', //
setSpecificaValue: '', //
setSpecificaValue2: '', //
// setSpecificaValue: '', //
// setSpecificaValue2: '', //
delivery_way: [], // 1 2
delivery_free: '0', // 0 1
temp_id: '', // ID
tempName: '' //
};
if (getStorage('editGoodsDetils')) {
removeStorage('editGoodsDetils');
}
productDetail(this.merId, this.product_id).then(res => {
setStorage('editGoodsDetils', res.data);
if(res.data.content_arr.length>0) res.data.content = res.data.content_arr;
this.$store.commit('setStorage', res.data);
productDetail(this.merId, this.product_id).then(async (res) => {
this.showCommodity = true;
if (res.data.content_arr.length > 0) res.data.content = res.data.content_arr;
let editGoodsDetils = res.data;
Object.keys(this.setFormData).forEach(item => {
this.setFormData[item] = editGoodsDetils[item];
@ -269,47 +385,55 @@
item => item
.category && item.category.cate_name).join(',') : '';
this.setFormData.brand_name = editGoodsDetils.brand ? editGoodsDetils.brand.brand_name : '';
//
if (this.setFormData.spec_type == 1) {
if (editGoodsDetils.attr.length) {
this.setFormData.specifica = '点击修改规格'
}
if (editGoodsDetils.attrValue.length) {
this.setFormData.setSpecificaValue2 = '点击修改价格'
if(typeof res.data.content == 'string')res.data.content = JSON.parse(res.data.content);
//
this.$refs.commodityRef.setDatas({
addGoodsSecoundData: {
is_good: res.data.is_good, //
is_gift_bag: res.data.is_gift_bag,
sort: res.data.sort,
once_count: res.data.once_count, //
video_link: res.data.video_link,
},
goodsDis: {
store_name: res.data.content?.title,
imageList: res.data.content?.image
}
})
//
if (this.setFormData.spec_type == 0) {
this.$refs.priceRef.setDatas(res.data.attrValue[0]);
}
if (editGoodsDetils.spec_type == 0) {
setStorage('singleSpecification', editGoodsDetils.attrValue[0]);
if (editGoodsDetils.attrValue.length) {
this.setFormData.setSpecificaValue = '点击修改价格'
}
}
setStorage('attrValue', editGoodsDetils.attrValue);
editGoodsDetils.temp && (this.setFormData.tempName = editGoodsDetils.temp.name);
setStorage('canChange', true);
hideLoading();
this.showCommodity = true;
});
},
//
async initClasiffy() {
this.merchantClassification = (await storeClassifyLst(this.merId)).data;
},
async initData() {
initData() {
//
this.brand = (await categoryBrandlist(this.merId)).data;
categoryBrandlist(this.merId).then((res)=>{
this.brand = res.data;
}).catch(e=>{
console.log(e);
});
//
let { data } = await categoryList(this.merId);
data.forEach((item1)=>{
item1.children.forEach((item2)=>{
item2.children = null;
categoryList(this.merId).then((res)=>{
res.data.forEach((item1) => {
item1.children.forEach((item2) => {
item2.children = null;
})
})
this.platformClassificationData = res.data;
}).catch(e=>{
console.log(e);
})
this.platformClassificationData = data;
},
//
updateCode(e){
updateCode(e) {
this.code = e + '';
},
//
@ -450,12 +574,117 @@
this.$refs.tempId.open();
});
},
//
submitCreatedGoods() {
console.log('创建商品');
console.log('商品数据', this.setFormData);
// return console.log('', this.setFormData.attr);
console.log('是否推荐', this.$refs.commodityRef.addGoodsSecoundData);
console.log('商品详情', this.$refs.commodityRef.goodsDis, this.$refs.commodityRef.store_name);
if(this.setFormData.spec_type==0){
console.log('价格库存', this.$refs.priceRef.singleSpecification);
}
let postData = {
...this.setFormData,
...this.$refs.commodityRef.addGoodsSecoundData,
content: {
title: this.$refs.commodityRef.goodsDis?.store_name || '',
image: this.$refs.commodityRef.goodsDis?.imageList || []
},
video_link: this.$refs.commodityRef.addGoodsSecoundData.video_link,
};
if(this.setFormData.spec_type==0){
postData.attrValue = [this.$refs.priceRef.singleSpecification];
}else postData.attrValue = this.setFormData.attrValue;
postData.stock = postData.attrValue[0]?.stock||0;
if(!postData.store_name||postData.store_name?.trim().length<=0)return Toast('请输入商品名称');
if(!postData.imageList||postData.imageList?.length<2)return Toast('请上传2张以上商品图片');
if(!postData.cate_name||postData.cate_name?.trim().length<=0)return Toast('请选择平台分类');
if(!postData.unit_name||postData.unit_name?.trim().length<=0)return Toast('请输入商品单位');
let userInfo = this.$store.state.app.userInfo;
if(typeof userInfo == 'string')userInfo= JSON.parse(userInfo);
let showFlag = '';
postData.attrValue.forEach(t=>{
if(userInfo?.mer_info?.type_code=="TypeSupplyChain" && (!t.procure_price||+t.procure_price<=0) ){
showFlag = '批发价不能小于0'
}
if(!t.price||+t.price<=0) showFlag = '零售价不能小于0';
if(!t.stock||+t.stock<=0) showFlag = '库存不能小于0';
if(!t.cost||+t.cost<=0) showFlag = '成本价不能小于0';
})
if(showFlag) {
if(this.setFormData.spec_type==1) showFlag+=', 请点击设置多规格设置';
return Toast(showFlag);
}
Loading();
if (this.product_id) {
productUpdate(this.merId, this.product_id, postData)
.then(res => {
hideLoading()
Modal('提交成功', '点击确定,返回商品管理', {
showCancel: false
}).then(() => {
uni.redirectTo({
url: '/pages/product/goodsOnSale/index?mer_id=' + this.merId
})
})
})
.catch(rej => {
Toast(rej);
});
} else {
productCreate(this.merId, postData)
.then(res => {
hideLoading();
Modal('提交成功', '点击确定,返回商品管理', {
showCancel: false,
}).then(() => {
if(this.import==1){
uni.$emit('importAttrValueOK', this.setFormData.import_id);
uni.navigateBack();
}
else uni.redirectTo({
url: '/pages/product/goodsOnSale/index?mer_id=' + this.merId
})
})
})
.catch(rej => {
Toast(rej);
});
}
},
//
changeSpecType(e){
if(this.setFormData.spec_type!=e.detail.value){
this.showSpecType = true;
}
this.spec_type = e.detail.value;
},
//
changeSpecType2(){
this.showSpecType = false;
this.setFormData.spec_type = this.spec_type + '';
this.setFormData.attrValue = [];
this.setFormData.attr = [];
},
//
navToSpecGood(){
uni.navigateTo({
url:'/pages/product/addGood/specGood?product_id=' + this.product_id,
success: (e) => {
// console.log(this.setFormData.attrValue, e);
e.eventChannel.emit('updateAttrValue', {
attrValue: JSON.parse(JSON.stringify(this.setFormData.attrValue)),
attr: JSON.parse(JSON.stringify(this.setFormData.attr))
});
uni.$once('updateSpecType', (e)=>{
this.setFormData.attrValue = JSON.parse(JSON.stringify(e.attrValue));
this.setFormData.attr = JSON.parse(JSON.stringify(e.attr));
})
}
})
}
}
};
</script>

View File

@ -164,13 +164,6 @@
},
mounted() {
this.initData();
// this.$nextTick(()=>{
// this.initData();
// })
},
updated() {
// this.initData();
},
methods: {
videoshow() {
@ -179,52 +172,10 @@
this.$nextTick(() => {
this.videoContext.play();
})
// this.video_link = this.formData.video_link;
// this.videoContext.requestFullScreen({ direction: 90 });
// this.videoContext.play(); this.videoplay = true;
},
initData() {
let editGoodsDetils = {};
if (getStorage('goodsDis')) {
this.disModel = true;
}
if (this.product_id) {
editGoodsDetils = this.$store.state.storage.storage;
Object.keys(this.addGoodsSecoundData).forEach(item => {
// console.log(item, editGoodsDetils[item]);
this.addGoodsSecoundData[item] = editGoodsDetils[item];
});
if (editGoodsDetils.content) {
this.goodsDis.imageList = editGoodsDetils.content.image;
this.goodsDis.store_name = editGoodsDetils.content.title;
this.store_name = editGoodsDetils.content.title;
// console.log(this.goodsDis, editGoodsDetils.content);
setStorage('goodsDis', {
store_name: editGoodsDetils.content.title,
imageList: editGoodsDetils.content.image
});
this.disModel = true;
}
setStorage('canChangeSecound', true);
return;
}else {
setStorage('goodsDis', {
store_name: '',
imageList: []
});
}
if (getStorage('addGoodsSecoundData')) {
Object.keys(this.addGoodsSecoundData).forEach(item => {
if (getStorage('addGoodsSecoundData')[item] || getStorage('addGoodsSecoundData')[item] == 0) {
this.addGoodsSecoundData[item] = getStorage('addGoodsSecoundData')[item];
}
});
}
},
lastStep() {
this.$emit('lastStep');
setDatas(data){
this.addGoodsSecoundData = data.addGoodsSecoundData;
this.goodsDis = data.goodsDis;
},
//
isGood(e) {

View File

@ -1,6 +1,6 @@
<template>
<view class="container">
<select-form style="border-radius: 10rpx 10rpx 0 0;" :platformClassification="formList" :form="singleSpecification"
<select-form :class="show_sku?'container_input':'border-radius'" :platformClassification="formList" :form="singleSpecification"
@input="input"></select-form>
<view class="more_than" @click="moreThanFlag?selectMoreThan():spliceMoreThan()">
<view v-if="moreThanFlag">更多</view>
@ -22,10 +22,11 @@
components: {
selectForm
},
props: ['product_id', 'bar_code'],
props: ['product_id', 'bar_code', 'datas', 'show_sku'],
data() {
return {
singleSpecification: {
// sku: '', //
price: '', //
cost: '', //
stock: '', //
@ -34,7 +35,7 @@
bar_code: '', //
weight: '', //
volume: '', //
image: '',
// image: '',
extension_one: '',
extension_two: ''
},
@ -106,27 +107,25 @@
}
},
watch: {
singleSpecification: {
handler(val, old) {
this.singleSpecification = val;
this.$emit('updateCode', val.bar_code);
},
deep: true
},
},
// watch: {
// singleSpecification: {
// handler(val, old) {
// console.log('', val);
// this.singleSpecification = val;
// },
// deep: true
// },
// },
mounted() {
if (getStorage('addGoodsFormData').image) {
this.singleSpecification.image = getStorage('addGoodsFormData').image;
}
if (getStorage('singleSpecification')) {
Object.keys(this.singleSpecification).forEach(item => {
if (getStorage('singleSpecification')[item]) {
this.singleSpecification[item] = getStorage('singleSpecification')[item]
}
this.singleSpecification.bar_code = this.$props.bar_code + '';
if(this.$props.datas){
// this.singleSpecification = this.$props.datas;
// this.$set(this, 'singleSpecification', this.$props.datas);
Object.keys(this.singleSpecification).forEach((key)=>{
this.singleSpecification[key] = this.$props.datas[key]
})
}
this.singleSpecification.bar_code = this.$props.bar_code + '';
let userInfo = this.$store.state.app.userInfo;
if(typeof userInfo == 'string') userInfo = JSON.parse(userInfo);
//
@ -160,9 +159,13 @@
spliceMoreThan() {
this.moreThanFlag = true;
// this.formList.splice(!this.$props.product_id ? 2 : 1, this.formList.length);
let len = 4;
if(this.$store.state.app?.userInfo?.mer_info?.type_code=="TypeSupplyChain")
this.formList.splice(4, this.formList.length);
else this.formList.splice(3, this.formList.length);
this.formList.splice(len, this.formList.length);
else this.formList.splice(len-1, this.formList.length);
},
setDatas(data){
this.singleSpecification = data;
},
input(val) {
this.singleSpecification = val
@ -214,4 +217,11 @@
border-radius: 43rpx;
}
}
.container_input{
margin-top: 0;
border-radius: 0;
}
.border-radius{
border-radius: 10rpx 10rpx 0 0;
}
</style>

View File

@ -0,0 +1,776 @@
<template>
<view class="page">
<view class="mode">
<view class="line">
<view class="title">规格模板</view>
<picker style="flex: 1;" mode="selector" :range="attr_mode_list" range-key="template_name" @change="changAttrMode">
<view class="input">
<view>{{template_name}}</view>
<uni-icons type="right"></uni-icons>
</view>
</picker>
<view class="btn" @click="preAddMode(3)">添加模板</view>
</view>
<view class="btn-box" @click="settingSpec()">
<view class="btn">点击设置规格</view>
</view>
<uni-popup ref="modeRef" type="top">
<view class="mode-ref" style="min-height: 300rpx;width: 100%;background-color: #fff;">
<view style="height: 1rpx;"></view>
<scroll-view scroll-y style="max-height: 550rpx;min-height: 220rpx;">
<view class="mode-item" v-for="(item, index) in attr" :key="item+index">
<view class="mode-head">{{item.value}}</view>
<view class="mode-body">
<view class="box mode-body-box" v-for="(t, i) in item.detail" :key="t+i"
@click="deleteAttrTow(index, i)">
{{t}}<uni-icons type="close" color="#f84221" style="margin-left: 10rpx;"></uni-icons>
</view>
<view class="box mode-body-add" @click="addSpecTow(index)"><uni-icons type="plus" color="#333"
style="margin-right: 10rpx;"></uni-icons></view>
</view>
<view class="delete-spec" @click="deleteAttrOne(index)"><uni-icons type="close" color="#f84221"
style="margin-right: 10rpx;"></uni-icons></view>
</view>
<view v-if="attr.length==0" style="color: #ccc;height: 220rpx;text-align: center;display: flex;flex-direction: column;justify-content: center;align-items: center;">
<view>暂无规格</view>
<view>点击下方按钮添加新规格</view>
</view>
</scroll-view>
<view class="tab">
<view class="add-btn" @click="addSpecOne()">添加新规格</view>
<view class="save" @click="saveAttrMode()">保存模板</view>
</view>
</view>
</uni-popup>
<uni-popup ref="inputModeRef" type="center">
<view class="input-mode">
<view class="head-tips">
<view v-if="addAttrType==1">添加规格值</view>
<view v-else-if="addAttrType==2">添加新规格</view>
<view v-else>添加模板</view>
</view>
<view class="input-box">
<input v-if="addAttrType==4||addAttrType==3" v-model="attrMode" placeholder="请输入模板名称" />
<input v-if="addAttrType==2||addAttrType==3" v-model="attrName" placeholder="请输入规格名称" />
<input v-if="addAttrType!=4" v-model="attrDetail" placeholder="请输入规格值" />
</view>
<view class="show-btn-box">
<view class="cof prai" @click="addAttr()">确认</view>
<view class="can" @click="closeAddAttr()">取消</view>
</view>
</view>
</uni-popup>
</view>
<view style="height: 160rpx;"></view>
<avatar style="height: 1px;" @upload="doUpload" @getName="getImgName" quality="1" ref="avatar" selWidth="250upx"
selHeight="250upx">
</avatar>
<block v-for="(item,index) in attrValue" :key="item.uuid">
<view class="popup_group head_close">
<view class="popup_group_item " v-for="(value, key) in item.detail" :key="key">
<view class="popup_group_item_label">{{key}}</view>
<view class="popup_group_item_value">
<input :value="value" type="text" disabled placeholder="请填写规格名称" />
</view>
</view>
<view class="delete_btn" @click="deleteByIndex(index)">
<image style="width: 50%;height: 50%;" src="../static/images/close.png"></image>
</view>
<view class="popup_group_item">
<view class="popup_group_item_label">规格图片</view>
<view style="width: 120rpx;height: 120rpx;position: relative;">
<block v-if="item.image">
<image @click="clk(item.uuid)" style="width: 120rpx;height: 120rpx;border-radius: 10rpx;"
:src="item.image"></image>
<view class="close-icon" @click="deleteImage(item)">
<image style="width: 50%;height: 50%;" src="../static/images/close.png"></image>
</view>
</block>
<view v-else
style="width: 120rpx;height: 120rpx;display: flex;justify-content: center;align-items: center;border: 1rpx solid #ccc;border-radius: 10rpx;">
<image @click="clk(item.uuid)" style="height: 60rpx;width: 60rpx;" src="../static/images/creamer.png">
</image>
</view>
</view>
</view>
</view>
<priceComponent ref="priceRef" :product_id="product_id" :datas="item" :bar_code="item.bar_code"
@updateCode="updateCode" :show_sku="true">
</priceComponent>
</block>
<!-- <button class="add_btn" @click="addAttrValue">点击添加规格</button> -->
<view class="submit">
<button class="btn" @click="submitAttr">确认<text>({{attrValue.length}})</text></button>
</view>
<u-modal title="警告" content="删除后数据不可恢复,是否确认删除?" :show="showDelete" show-cancel-button @cancel="showDelete=false"
@confirm="deleteAttr()"></u-modal>
</view>
</template>
<script>
import priceComponent from "./components/price.vue";
import avatar from "@/components/yq-avatar/yq-avatar.vue";
import { TOKENNAME, HTTP_REQUEST_URL } from '@/config/app.js';
import { Toast } from "../../../libs/uniApi";
import {
specificationUpdate,
attrList,
specificationAdd
} from "@/api/product.js"
export default {
components: {
priceComponent,
avatar
},
data() {
return {
attrValue: [],
attr: [],
attr_mode_list: [], //
template_name: '点击选择模板', //
attr_mode: { //
"detail": {},
"sku": "",
"stock": 0,
"image": "",
"bar_code": "",
"cost": "",
"ot_price": "",
"price": "",
"volume": "",
"weight": "",
},
product_id: '',
uuid: '', //id
deleteIndex: '', //
showDelete: false,
userInfo: {},
addAttrType: 1, // , 1, 2, 3, 4
attrName: '', //
attrDetail: '', //
attrMode: '', //
changeAttr: 0, //
}
},
onLoad(options) {
this.product_id = options.product_id;
this.attrValue = JSON.parse(uni.getStorageSync('attrValue') || '[]');
this.attr = JSON.parse(uni.getStorageSync('attr') || '[]');
this.getOpenerEventChannel().once('updateAttrValue', (e) => {
e.attrValue.forEach((item, index) => {
item.uuid = Date.now() + '-' + Math.floor(Math.random() * 10000);
})
this.attrValue = e.attrValue;
uni.setStorageSync('attrValue', JSON.stringify(e.attrValue));
this.attr = e.attr;
uni.setStorageSync('attr', JSON.stringify(e.attr));
})
this.userInfo = this.$store.state.app.userInfo;
if (typeof this.userInfo == 'string') this.userInfo = JSON.parse(this.userInfo);
this.initAttrModeList();
},
methods: {
updateCode(e) {
console.log(e);
},
//
settingSpec() {
this.$refs.modeRef.open();
},
//
addSpecTow(index) {
this.attrDetail = '';
this.addAttrType = 1;
this.changeAttr = index;
this.$refs.inputModeRef.open();
},
//
addSpecOne() {
this.attrName = '';
this.attrDetail = '';
this.addAttrType = 2;
this.$refs.inputModeRef.open();
},
//
deleteAttrTow(i, j) {
if(this.attr[i].detail.length<=1){
return this.deleteAttrOne(i); // ,
}
this.attrValue = this.attrValue.filter(item=>{
return !(item.detail[this.attr[i].value] == this.attr[i].detail[j]);
})
this.attr[i].detail.splice(j, 1);
},
//
deleteAttrOne(i) {
let attr = this.attr[i];
if(this.attr.length==1){ // , ,
this.$set(this, 'attrValue', []);
this.attr.splice(i, 1);
return ;
}
//
this.attrValue.forEach(item => {
let a = item.sku.split(',');
a = a.filter(e=>e!=item.detail[attr.value]);
item.sku = a.join(',');
delete item.detail[attr.value];
})
//
this.attrValue = Array.from(new Set(this.attrValue.map(item => item.sku))).map(sku => {
return this.attrValue.find(item => item.sku === sku);
});
this.attr.splice(i, 1);
},
//
addAttrValueCard(){
let arr = this.computeAttr(this.attr); // sku
let t = [];
let keys = this.attr.map(e => { //
return e.value;
})
let temp = [];
arr.forEach((sku) => { // sku
if (this.attrValue.find(e => e.sku == sku)) return;
else {
let detail = {};
let t = sku.split(',');
keys.forEach((e, i) => { // detail
detail[e] = t[i];
})
temp.push(Object.assign({}, this.attr_mode, {
sku: sku,
detail: detail,
uuid: Date.now() + '-' + Math.floor(Math.random() * 10000) // uuid
})) //
}
})
setTimeout(() => {
this.attrValue = [...this.attrValue, ...temp] //
})
},
//
closeAddAttr() {
this.$refs.inputModeRef.close();
},
//
computeAttr(arr) {
let s = [];
arr.forEach(item => {
s.push(item.detail);
})
let t = this.getCombination(s);
t = t.map(item => {
if (typeof item == 'object') {
return item.join(',')
} else return item;
})
return t;
},
//
getCombination(arr) {
if (arr.length === 1) {
return arr[0];
}
var result = [];
var first = arr[0];
var rest = arr.slice(1);
for (var i = 0; i < first.length; i++) {
var subResult = this.getCombination(rest);
for (var j = 0; j < subResult.length; j++) {
result.push([first[i]].concat(subResult[j]));
}
}
return result;
},
//
addAttr() {
this.attrDetail = this.attrDetail.trim();
this.attrDetail = this.attrDetail.trim();
if (this.addAttrType == 1) { // 2
if (this.attr[this.changeAttr].detail.find(name => name == this.attrDetail)) {
this.closeAddAttr();
this.$nextTick(() => {
Toast('该规格已存在')
})
} else {
this.attr[this.changeAttr].detail.push(this.attrDetail);
this.closeAddAttr();
setTimeout(()=>{
this.addAttrValueCard();
})
}
} else if (this.addAttrType == 2) { // 1
if (this.attr.find(item => item.value == this.attrName)) {
this.closeAddAttr();
this.$nextTick(() => {
Toast('该规格已存在')
})
} else {
console.log('添加新规格');
this.attr.push({
value: this.attrName,
detail: [this.attrDetail]
});
if(this.attrValue.length){
this.attrValue.forEach((item) => {
item.detail[this.attrName] = this.attrDetail;
item.sku = item.sku + ',' + this.attrDetail;
})
}
else {
let detail = {};
detail[this.attrName] = this.attrDetail;
this.attrValue.push(Object.assign({}, this.attr_mode, {
sku: this.attrDetail,
detail: detail,
uuid: Date.now() + '-' + Math.floor(Math.random() * 10000)
}))
}
this.closeAddAttr();
}
} else if (this.addAttrType == 3 || this.addAttrType == 4){
this.addNewAttrMode();
}
},
//
saveAttrMode() {
if(this.attr.length<=0)return Toast('不可保存空模板');
if(this.attr_template_id){
this.addAttrType = 4;
let template = this.attr_mode_list.find(e=>e.attr_template_id==this.attr_template_id);
specificationUpdate(this.userInfo.service.mer_id, this.attr_template_id, {
attr_template_id: template.attr_template_id,
mer_id: template.attr_template_id,
template_name: template.template_name,
template_value: this.attr
}).then((res)=>{
this.$refs.modeRef.close();
this.$nextTick(()=>{
Toast('保存成功');
})
}).catch(err=>{
Toast(err)
})
}else {
this.preAddMode(4)
}
},
//
addNewAttrMode(){
this.attrMode = this.attrMode.trim(' ');
if(this.attrMode==''||this.attrMode===undefined||this.attrMode===null){
return Toast('模板名称不可为空')
}
let attr = [];
if(this.addAttrType==3){
attr[0] = {};
attr[0].value = this.attrName;
attr[0].detail = [];
attr[0].detail[0] = this.attrDetail;
}else attr = this.attr;
specificationAdd(this.userInfo.service.mer_id, {
template_name: this.attrMode,
template_value: attr
}).then((res)=>{
this.initAttrModeList();
this.closeAddAttr();
this.$nextTick(()=>{
this.$refs.modeRef.close();
this.$nextTick(()=>{
Toast('保存成功');
})
})
}).catch(err=>{
Toast(err)
})
},
//
preAddMode(type=3){
this.attrName = '';
this.attrDetail = '';
this.attrMode = '';
this.addAttrType = type;
this.$refs.inputModeRef.open();
},
//
submitAttr() {
if (this.attrValue.length < 1) return Toast('请至少添加一种规格');
let flag = true;
let str = '请填写完整信息';
this.attrValue.forEach((item, index) => {
Object.keys(this.$refs.priceRef[index].singleSpecification).forEach(key => {
item[key] = this.$refs.priceRef[index].singleSpecification[key];
})
if (flag) {
if (item.sku == undefined || item.sku == null || item.sku == '') {
flag = false;
str = '规格不能为空';
}
else if (!item.price||+item.price<=0) {
flag = false;
str = '零售价不能小于等于0';
}
else if (!item.stock||+item.stock<=0) {
flag = false;
str = '库存不能小于等于0';
}
else if (!item.cost||+item.cost<=0) {
flag = false;
str = '成本价不能小于等于0';
}
else if ((!item.procure_price||+item.procure_price<=0) && this.userInfo.mer_info.type_code == 'TypeSupplyChain') {
flag = false;
str = '批发价不能小于等于0';
}
}
})
if (!flag) return Toast(str);
else {
uni.$emit('updateSpecType', {
attr: this.attr,
attrValue: this.attrValue
});
uni.navigateBack();
}
},
//
clk(uuid) {
this.uuid = uuid;
let avatar = this.$refs.avatar;
avatar.fChooseImg(1, { selWidth: '350upx', selHeight: '350upx', inner: true });
},
doUpload(rsp) {
// console.log(rsp);
let that = this
uni.uploadFile({
url: HTTP_REQUEST_URL + '/api/upload/image/field',
filePath: rsp.path,
name: 'field',
formData: {
'filename': rsp.path,
'name': that.imgName
},
header: {
// #ifdef MP
"Content-Type": "multipart/form-data",
// #endif
[TOKENNAME]: 'Bearer ' + this.$store.state.app.token
},
success: (uploadFileRes) => {
let imgData = JSON.parse(uploadFileRes.data)
let item = this.attrValue.find(item => item.uuid == this.uuid);
item.image = imgData.data.path;
},
complete(res) {
// console.log(res)
}
});
},
getImgName(name) {
this.imgName = name
},
//
deleteImage(item) {
item.image = '';
},
//
addAttrValue() {
this.attrValue.push(Object.assign({}, this.attr_mode, {
uuid: Date.now() + '-' + Math.floor(Math.random() * 10000) // uuid
}))
},
//
deleteByIndex(index) {
this.deleteIndex = index;
this.showDelete = true;
},
//
deleteAttr() {
this.attrValue.splice(this.deleteIndex, 1);
this.showDelete = false;
},
//
initAttrModeList(){
attrList(this.userInfo.service.mer_id,{
page: 1,
limit: 10000
}).then((res)=>{
console.log(res);
this.attr_mode_list = res.data.list;
})
},
changAttrMode(e){
this.attr_template_id = this.attr_mode_list[e.detail.value].attr_template_id;
this.template_name = this.attr_mode_list[e.detail.value].template_name;
this.attr = JSON.parse(JSON.stringify(this.attr_mode_list[e.detail.value].template_value));
this.$set(this, 'attrValue', []);
this.addAttrValueCard();
}
},
onBackPress: () => {
}
}
</script>
<style lang="scss">
@import './scss/index.scss';
.page{
padding-bottom: 150rpx;
}
.popup_group {
margin-bottom: 0;
}
.popup_group_item {
border-bottom: 1rpx solid #eee;
padding-left: 18rpx !important;
.close-icon {
position: absolute;
top: 0;
right: 0;
width: 30rpx;
height: 30rpx;
border-radius: 10rpx;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
background-color: rgba(#000, 0.4);
color: #fff;
}
}
.head_close {
position: relative;
.delete_btn {
position: absolute;
top: -15rpx;
right: -15rpx;
width: 40rpx;
height: 40rpx;
display: flex;
justify-content: center;
align-items: center;
background-color: red;
color: #fff;
border-radius: 50%;
}
}
.add_btn {
width: 710rpx;
margin: 28rpx auto;
margin-bottom: 160rpx;
font-size: 30rpx;
padding: 28rpx;
color: #333;
}
.submit {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
background-color: #fff;
padding: 20rpx 0;
.btn {
width: 694rpx;
height: 80rpx;
margin: 0 auto;
background: #e93323;
border-radius: 43px;
display: flex;
align-items: center;
justify-content: center;
font-size: 15px;
color: #ffffff;
}
}
.mode {
width: 100%;
background-color: #fff;
position: fixed;
top: 0;
left: 0;
z-index: 1;
.line {
padding: 0 28rpx;
height: 80rpx;
display: flex;
justify-content: space-between;
align-items: center;
font-size: 28rpx;
.btn {
background-color: #f84221;
color: #fff;
width: 140rpx;
height: 50rpx;
display: flex;
justify-content: center;
align-items: center;
border-radius: 10rpx;
}
.input {
flex: 1;
padding: 0 16rpx;
display: flex;
justify-content: space-between;
align-items: center;
}
}
.btn-box {
height: 80rpx;
display: flex;
justify-content: center;
align-items: center;
border-top: 1rpx solid #eee;
border-bottom: 1rpx solid #eee;
}
.mode-ref {
.mode-item {
margin: 20rpx;
border: 1rpx solid #eee;
border-radius: 10rpx;
font-size: 26rpx;
position: relative;
overflow: hidden;
.mode-head {
padding-top: 20rpx;
padding-left: 20rpx;
font-size: 32rpx;
font-weight: bold;
}
.mode-body {
display: flex;
flex-wrap: wrap;
padding: 20rpx;
padding-left: 0;
.box {
padding: 10rpx 20rpx;
border: 1px solid #f84221;
margin-left: 20rpx;
border-radius: 10rpx;
margin-bottom: 10rpx;
background-color: rgba(#f84221, 0.1);
color: #f84221;
display: flex;
justify-content: center;
align-items: center;
}
.mode-body-add {
border: 1rpx solid #ddd;
background-color: #fff;
color: #333;
}
}
.delete-spec {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
top: 0;
right: 0;
background-color: #eee;
padding: 5rpx;
border-radius: 0 0 0 10rpx;
color: #f84221;
}
}
.tab {
padding: 20rpx;
border-top: 1rpx solid #eee;
display: flex;
font-size: 28rpx;
.add-btn {
flex: 1;
background-color: #f84221;
color: #fff;
padding: 10rpx;
text-align: center;
border-radius: 10rpx;
}
.save {
color: #333;
border: 1rpx solid #ddd;
padding: 10rpx;
text-align: center;
border-radius: 10rpx;
margin-left: 20rpx;
}
}
}
.input-mode {
width: 694rpx;
padding: 28rpx;
font-size: 28rpx;
border-radius: 10rpx;
background-color: #fff;
.head-tips {
font-size: 32rpx;
font-weight: bold;
text-align: center;
padding-bottom: 20rpx;
}
.input-box {
input {
height: 80rpx;
margin-bottom: 20rpx;
font-size: 28rpx;
border: 1rpx solid #ddd;
padding: 0 20rpx;
border-radius: 10rpx;
}
}
.show-btn-box {
width: 100%;
display: flex;
justify-content: space-between;
.cof,
.can {
height: 80rpx;
line-height: 80rpx;
width: 300rpx;
text-align: center;
border: 1rpx solid #ddd;
border-radius: 10rpx;
}
.prai {
background-color: #f84221;
border: 1rpx solid #f84221;
color: #fff;
}
}
}
}
</style>

View File

@ -597,6 +597,7 @@
productDetail(this.merId, this.product_id).then(res => {
setStorage('editGoodsDetils', res.data);
if(res.data.content_arr.length>0) res.data.content = res.data.content_arr;
if(typeof res.data.content == 'string')res.data.content = JSON.parse(res.data.content);
this.$store.commit('setStorage', res.data);
let editGoodsDetils = res.data;
Object.keys(this.setFormData).forEach(item => {

View File

@ -55,7 +55,7 @@
<view v-if="item.is_show == 0 && item.status == 1 && type != 5" class="shop_button" @click="upperShelfAndLowerShelf(item, index)">上架</view>
<view class="shop_button" v-if="type != 1 && type != 3" @click="handleDelete(item, index)">删除</view>
<view class="shop_button" v-if="type == 5" @click="reduction(item, index)">恢复</view>
<navigator :url="`/pages/product/addGoods/index?mer_id=${merId}&product_id=${item.product_id}`" v-if="type != 5" class="shop_button" hover-class="none">编辑</navigator>
<navigator :url="`/pages/product/addGood/addGood?mer_id=${merId}&product_id=${item.product_id}`" v-if="type != 5" class="shop_button" hover-class="none">编辑</navigator>
</view>
</view>
</view>
@ -209,7 +209,7 @@ export default {
removeStorage(item);
}
});
navigateTo(1, '/pages/product/addGoods/index', { mer_id: this.merId, type: 'edit', product_id: item.product_id, type: 'edit' });
navigateTo(1, '/pages/product/addGood/addGood', { mer_id: this.merId, type: 'edit', product_id: item.product_id, type: 'edit' });
},
//
handleDelete(item, index) {

View File

@ -9,6 +9,17 @@
<block>
<swiper-item :class="{ active: 0 == swiperCur }">
<view class="slide-navigator">
<picker class="item"
mode="multiSelector"
:range="[menuList,menuCList]"
:range-key="'cate_name'"
@columnchange="columnchange"
@change="changeMenu"
@cancel="cancelMenu"
>
<image mode='widthFix' class="image" src="@/static/images/daoru.png"></image>
<text class="text">分类筛选</text>
</picker>
<!-- <view class="item" hover-class='none' @click="jumpAddGoods">
<image mode='widthFix' class="image" src="../static/images/product_add.png">
</image>
@ -74,6 +85,16 @@
</view>
<view class="wrapper">
<view class='product_list'>
<!-- <view class="menu_cls">
<u-scroll-list indicatorActiveColor='#FF6D20' :indicator="true">
<view class="menu_li" :class="{'menu_li_on': item.store_category_id==store_category_id}" @click="changeMerchant(item.store_category_id)" v-for="item,index in menuList"
:key="index">
<u--image class="image" :showLoading="true" :src="item.pic" width="87.62rpx" height="87.62rpx" shape="circle"
></u--image>
<view class="li_text" style="display: block;font-size: 26.29rpx;margin-top: 10rpx;">{{item.cate_name}}</view>
</view>
</u-scroll-list>
</view> -->
<view v-for="(item,index) in productList" :key="index" style="position: relative;width: 100%;">
<view class='item' @click="yinc">
<view class='image'>
@ -217,6 +238,9 @@
import {
getPreviewProDetail
} from "@/api/store.js";
import {
getCategoryListLevel
} from '@/api/requesta.js';
export default {
name: 'productList',
components: {
@ -230,6 +254,9 @@
page: 1,
limit: 20
},
menuList: [], //
menuCList: [], //
cate_id: '', // id
loaded: false,
loading: false,
mer_id: '',
@ -263,7 +290,12 @@
onLoad(options) {
// this.mer_id = options.mer_id;
this.getUserInfo()
getCategoryListLevel({
type: 2
}).then(res => {
this.menuList = res.data;
this.menuCList = res.data[0].children;
})
},
onPullDownRefresh() {
this.where.page = 1
@ -389,7 +421,7 @@
Fline(item) {
this.checkboxList1 = item.attrValue
// console.log(this.checkboxList1.length)
if (this.checkboxList1.length>1){
if (this.checkboxList1.length>0){
navigateTo(1, '/pages/product/updateStock/updateStock', {
product_id: item.product_id
})
@ -541,7 +573,7 @@
}
})
}
navigateTo(1, '/pages/product/addGoods/index', {
navigateTo(1, '/pages/product/addGood/addGood', {
mer_id: this.mer_id
});
},
@ -557,20 +589,24 @@
}
},
getList: function(mer_id, ispage) {
console.log('调用');
var that = this;
if (that.loading || that.loaded) return;
that.loading = true;
if (ispage) {
this.where.page = 1
that.productList = []
this.$set(this, 'productList', []);
}
if(this.cate_id.store_category_id){
that.where.cate_id = this.cate_id.store_category_id;
// mer_cate_id
}
productLstApi(mer_id, that.where).then(
res => {
that.loading = false;
that.loaded = res.data.list.length < that.where.limit;
that.productList.push.apply(that.productList, res.data.list);
that.where.page = that.where.page + 1;
},
error => {
that.$util.Tips({
@ -580,23 +616,23 @@
);
},
editGoods(item) {
let waitDeleteData = [
'addGoodsFormData',
'singleSpecification',
'attrValue',
'modifyPriceData',
'addGoodsSecoundData',
'goodsDis',
'editGoodsDetils',
'canChange',
'canChangeSecound'
];
waitDeleteData.forEach(item => {
if (getStorage(item)) {
removeStorage(item);
}
});
navigateTo(1, '/pages/product/addGoods/index', {
// let waitDeleteData = [
// 'addGoodsFormData',
// 'singleSpecification',
// 'attrValue',
// 'modifyPriceData',
// 'addGoodsSecoundData',
// 'goodsDis',
// 'editGoodsDetils',
// 'canChange',
// 'canChangeSecound'
// ];
// waitDeleteData.forEach(item => {
// if (getStorage(item)) {
// removeStorage(item);
// }
// });
navigateTo(1, '/pages/product/addGood/addGood', {
mer_id: item.mer_id,
product_id: item.product_id
});
@ -689,6 +725,26 @@
more(index) {
this.current = index
},
//
columnchange(e){
if(e.detail.column==0){
this.menuCList = this.menuList[e.detail.value].children;
}
},
changeMenu(e){
let cate_id = this.menuList[e.detail.value[0]].children[e.detail.value[1]]||this.menuList[e.detail.value[0]]||'';
this.$set(this, 'cate_id', JSON.parse(JSON.stringify(cate_id)));
this.loading = false;
this.loaded = false;
this.getList(this.mer_id, true)
},
cancelMenu(){
this.loading = false;
this.loaded = false;
this.where.cate_id = null;
this.cate_id.store_category_id = null;
this.getList(this.mer_id, true)
}
},
}
@ -1065,4 +1121,52 @@
}
}
}
.menu_cls {
background-color: white;
// height: 199.77rpx;
border-radius: 10rpx;
padding: 20rpx 20rpx 0 20rpx;
margin-top: 20rpx;
font-size: 26.29rpx;
height: 220rpx;
width: 100%;
.menu_li {
// margin-right: 20rpx;
// background-color: red;
// width: 50vw;
display: flex;
flex-direction: column;
align-items: center;
min-width: 140rpx;
height: auto;
// width: 120rpx;
// display: inline-block;
.image{
border: 5rpx solid #fff;
}
.li_text{
flex: 1;
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
text-align: center;
padding: 1rpx 10rpx 4rpx 10rpx;
}
}
.menu_li_on{
.image{
border: 5rpx solid #ff6d20;
border-radius: 50%;
}
.li_text{
background-color: #ff6d20;
border-radius: 2em;
color: #fff;
padding: 1rpx 10rpx 4rpx 10rpx;
}
}
}
</style>

View File

@ -13,7 +13,10 @@
<image :src="item.image||short.image||defualtImg"></image>
</view>
<view class="td sku">
<view v-for="name in item.sku.split(',')">{{name}}</view>
<block v-if="item.sku">
<view v-for="name in item.sku.split(',')">{{name}}</view>
</block>
<view v-else>{{short.store_name}}</view>
</view>
<view class="td stock">
<input type="number" v-model="item.stock" />
@ -156,7 +159,7 @@ import { Toast } from '../../../libs/uniApi';
}
}
.sku{
padding: 16rpx 0;
padding: 16rpx 16rpx;
}
}
}