|
@@ -76,7 +76,13 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="menu" v-if="hasNameList === 0">
|
|
|
- <input class="input-shopname" type="text" v-model="shopname" placeholder-style="color:#a2a8a8;font-size:30upx" placeholder="请输入商品名称">
|
|
|
+ <input
|
|
|
+ class="input-shopname"
|
|
|
+ type="text"
|
|
|
+ v-model="shopname"
|
|
|
+ placeholder-style="color:#a2a8a8;font-size:30upx"
|
|
|
+ placeholder="请输入商品名称"
|
|
|
+ />
|
|
|
</view>
|
|
|
</view>
|
|
|
<!-- 自定义分类 -->
|
|
@@ -133,7 +139,7 @@
|
|
|
<!-- 商品图标 -->
|
|
|
<view class="shopicon">商品图标</view>
|
|
|
<view class="iconcontent">
|
|
|
- <image class="shopLogo" :src="img" v-if="img"></image>
|
|
|
+ <image class="shopLogo" :src="iconurl" v-if="iconurl"></image>
|
|
|
<text class="icon" @tap="uploadImg">点击上传</text>
|
|
|
</view>
|
|
|
<view class="shopicon">商品图册</view>
|
|
@@ -172,11 +178,13 @@
|
|
|
</view>
|
|
|
|
|
|
<view class="btn" @tap="submitMesage">确认</view>
|
|
|
+ <rf-loading v-if="loading"></rf-loading>
|
|
|
</view>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+let myCloud;
|
|
|
import Header from '../components/header.vue';
|
|
|
export default {
|
|
|
components: {
|
|
@@ -184,13 +192,13 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ loading: false,
|
|
|
scenicId: uni.getStorageSync('scenicId'),
|
|
|
title: '商品详情',
|
|
|
num1: 1,
|
|
|
num2: 10,
|
|
|
showoperat: false,
|
|
|
- img: '',
|
|
|
- pickList: [],
|
|
|
+
|
|
|
placeholder: '请输入内容...',
|
|
|
mastKnow: '',
|
|
|
storeList: [{ name: '所属店铺', id: '' }],
|
|
@@ -211,26 +219,38 @@ export default {
|
|
|
lineList: [{ name: '分类(请先选择所属商品)', id: '' }],
|
|
|
lineIndex: 0,
|
|
|
lineId: '',
|
|
|
+
|
|
|
+ // 图标上传
|
|
|
+ iconurl: '',
|
|
|
+ pickList: [],
|
|
|
+ Icon: '',
|
|
|
+ Imglist: [],
|
|
|
};
|
|
|
},
|
|
|
onLoad() {
|
|
|
+ // 初始化阿里云
|
|
|
+ myCloud = uniCloud.init({
|
|
|
+ provider: 'aliyun',
|
|
|
+ spaceId: 'db8671a1-69bd-470d-ad59-ba927c88f4a4',
|
|
|
+ clientSecret: '8nOzV70edtpCd0El6qce3g==',
|
|
|
+ });
|
|
|
this.getShopList();
|
|
|
},
|
|
|
methods: {
|
|
|
// 跳转到管理分类页面
|
|
|
toClassify() {
|
|
|
if (this.storeId) {
|
|
|
- uni.setStorageSync('shopid',this.storeId)
|
|
|
+ uni.setStorageSync('shopid', this.storeId);
|
|
|
this.$mRouter.push({ route: '/pages/shop/classify' });
|
|
|
} else {
|
|
|
- this.$mHelper.toast('请选择所属店铺后再进行自定义分类管理')
|
|
|
+ this.$mHelper.toast('请选择所属店铺后再进行自定义分类管理');
|
|
|
}
|
|
|
},
|
|
|
// 选择店铺
|
|
|
changeStore(e) {
|
|
|
this.storeIndex = e.detail.value;
|
|
|
this.storeId = this.storeList[this.storeIndex].id;
|
|
|
-
|
|
|
+
|
|
|
// 未选择商铺不能进行商铺类型选择
|
|
|
if (this.storeId != '') {
|
|
|
this.getType();
|
|
@@ -257,7 +277,7 @@ export default {
|
|
|
},
|
|
|
// 所属店铺
|
|
|
async getShopList() {
|
|
|
- this.storeList = [{ name: '所属店铺', id: '' }]
|
|
|
+ this.storeList = [{ name: '所属店铺', id: '' }];
|
|
|
await this.$http
|
|
|
.get('/shop/getList', {
|
|
|
mid: this.scenicId,
|
|
@@ -274,7 +294,7 @@ export default {
|
|
|
},
|
|
|
// 商品类型
|
|
|
async getType() {
|
|
|
- this.typeList = [{ name: '商品类型(请先选择所属店铺)', id: '' }]
|
|
|
+ this.typeList = [{ name: '商品类型(请先选择所属店铺)', id: '' }];
|
|
|
this.$http
|
|
|
.get('/type/getTypeListByShopId', {
|
|
|
id: this.storeId,
|
|
@@ -289,7 +309,7 @@ export default {
|
|
|
},
|
|
|
// 商品名称
|
|
|
async getShopName() {
|
|
|
- this.shopList = [{ name: '商品名称(请先选择商品类型)', id: '' }]
|
|
|
+ this.shopList = [{ name: '商品名称(请先选择商品类型)', id: '' }];
|
|
|
await this.$http
|
|
|
.get('/goods/getTicketGoods', {
|
|
|
typeId: this.typeId,
|
|
@@ -357,34 +377,27 @@ export default {
|
|
|
sourceType: ['album'], // camera 使用相机 album 从相册中选
|
|
|
success: function (res) {
|
|
|
// 成功则返回图片的本地文件路径列表 tempFilePaths
|
|
|
- _self.img = res.tempFilePaths[0];
|
|
|
+ _self.iconurl = res.tempFilePaths[0];
|
|
|
|
|
|
- let myCloud = uniCloud.init({
|
|
|
- provider: 'aliyun',
|
|
|
- spaceId: 'bc6ff3c9-ac50-449a-aa09-38ec42b68dc3',
|
|
|
- clientSecret: 'i0TfgbVL3IB/nTeqtWOJbw=='
|
|
|
- });
|
|
|
+ console.log(_self.iconurl);
|
|
|
|
|
|
myCloud.uploadFile({
|
|
|
- url: 'http://192.168.100.135:83/merch/common/upload/oss', // 是否包含baseurl???
|
|
|
- filePath: _self.img, // 要上传的文件对象
|
|
|
- cloudPath: _self.img,
|
|
|
+ url: 'http://192.168.100.135:83/merch/common/upload/oss',
|
|
|
+ filePath: _self.iconurl, // 要上传的文件对象
|
|
|
+ cloudPath: _self.iconurl,
|
|
|
name: 'file',
|
|
|
onUploadProgress: function (progressEvent) {
|
|
|
// 上传进度回调
|
|
|
- console.log(progressEvent);
|
|
|
let percentCompleted = Math.round(
|
|
|
(progressEvent.loaded * 100) / progressEvent.total
|
|
|
);
|
|
|
+ console.log(percentCompleted);
|
|
|
},
|
|
|
- success: (res) =>{
|
|
|
- console.log(res);
|
|
|
- },
|
|
|
- fail:(error)=> {
|
|
|
- console.log(error);
|
|
|
- },
|
|
|
- complete:(msg)=> {
|
|
|
- console.log(msg);
|
|
|
+ success: (res) => {
|
|
|
+ if (res.fileID) {
|
|
|
+ _self.Icon = res.fileID;
|
|
|
+ console.log(_self.Icon);
|
|
|
+ }
|
|
|
},
|
|
|
});
|
|
|
},
|
|
@@ -399,20 +412,37 @@ export default {
|
|
|
sourceType: ['album'], // camera 使用相机 album 从相册中选
|
|
|
success: function (res) {
|
|
|
// 成功则返回图片的本地文件路径列表 tempFilePaths
|
|
|
- console.log(res.tempFilePaths);
|
|
|
let img = [];
|
|
|
img.push(res.tempFilePaths);
|
|
|
if (_self.pickList.length >= 6) {
|
|
|
_self.$mHelper.toast('最多只可上传6张图片');
|
|
|
} else {
|
|
|
_self.pickList = _self.pickList.concat(img);
|
|
|
+ // for (let i = 0; i < _self.pickList.length; i++) {
|
|
|
+ // let element = _self.pickList[i];
|
|
|
+ // myCloud.uploadFile({
|
|
|
+ // url: 'http://192.168.100.135:83/merch/common/upload/oss',
|
|
|
+ // filePath: element, // 要上传的文件对象
|
|
|
+ // cloudPath: element,
|
|
|
+ // name: 'file',
|
|
|
+ // onUploadProgress: function (progressEvent) {
|
|
|
+ // // 上传进度回调
|
|
|
+ // let percentCompleted = Math.round(
|
|
|
+ // (progressEvent.loaded * 100) / progressEvent.total
|
|
|
+ // );
|
|
|
+ // console.log(percentCompleted);
|
|
|
+ // },
|
|
|
+ // success: (res) => {
|
|
|
+ // console.log(res);
|
|
|
+ // },
|
|
|
+ // });
|
|
|
+ // }
|
|
|
}
|
|
|
},
|
|
|
});
|
|
|
},
|
|
|
// 删除图册中的图片
|
|
|
deleteThisImg(index) {
|
|
|
- console.log(index);
|
|
|
this.pickList.splice(index, 1);
|
|
|
},
|
|
|
// 富文本失去焦点保存内容
|
|
@@ -425,6 +455,8 @@ export default {
|
|
|
// },
|
|
|
// 内容提交
|
|
|
submitMesage() {
|
|
|
+ let _this = this;
|
|
|
+ this.loading = true;
|
|
|
let astrictDate = {};
|
|
|
// 判断是否限制账号购买
|
|
|
if (this.showoperat) {
|
|
@@ -440,31 +472,28 @@ export default {
|
|
|
astrictDate = '';
|
|
|
}
|
|
|
// 判断是否可以自定义商品名称
|
|
|
- let name = ''
|
|
|
- if (this.shopList.length = 1) {
|
|
|
- name = this.shopname
|
|
|
+ let name = '';
|
|
|
+ if ((this.shopList.length = 1)) {
|
|
|
+ name = this.shopname;
|
|
|
} else {
|
|
|
- name = this.shopList[this.shopIndex].id
|
|
|
+ name = this.shopList[this.shopIndex].id;
|
|
|
}
|
|
|
-
|
|
|
- console.log(this.storeId);
|
|
|
- console.log(this.typeId);
|
|
|
- console.log(name);
|
|
|
-
|
|
|
if (!this.storeId) {
|
|
|
- this.$mHelper.toast('请选择所属商铺')
|
|
|
- return
|
|
|
+ this.$mHelper.toast('请选择所属商铺');
|
|
|
+ this.loading = false;
|
|
|
+ return;
|
|
|
}
|
|
|
if (!this.typeId) {
|
|
|
- this.$mHelper.toast('请选择商品类型')
|
|
|
- return
|
|
|
+ this.$mHelper.toast('请选择商品类型');
|
|
|
+ this.loading = false;
|
|
|
+ return;
|
|
|
}
|
|
|
if (!name) {
|
|
|
- this.$mHelper.toast('请选择商品名称或者输入商品名称')
|
|
|
- return
|
|
|
+ this.$mHelper.toast('请选择商品名称或者输入商品名称');
|
|
|
+ this.loading = false;
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
- return
|
|
|
this.$http
|
|
|
.post('/goods/add', {
|
|
|
mid: this.scenicId,
|
|
@@ -475,12 +504,14 @@ export default {
|
|
|
saleRule: this.showoperat,
|
|
|
saleRuleJson: JSON.stringify(astrictDate),
|
|
|
describ: this.mastKnow,
|
|
|
+ icon: this.Icon || '',
|
|
|
})
|
|
|
.then((res) => {
|
|
|
if (res.code === 200 && res.msg === 'OK') {
|
|
|
- this.$mHelper.toast('添加成功')
|
|
|
+ this.$mHelper.toast('添加成功');
|
|
|
+ this.loading = false;
|
|
|
setTimeout(() => {
|
|
|
- this.$mRouter.back()
|
|
|
+ this.$mRouter.back();
|
|
|
}, 500);
|
|
|
}
|
|
|
});
|