提交udesk方案

master
lemon橪 2021-12-20 16:48:08 +08:00
parent 246ba9057f
commit 44facf549a
3 changed files with 130 additions and 79 deletions

View File

@ -81,3 +81,14 @@ export function articleDetail (id) {
method: Method.GET method: Method.GET
}); });
} }
// 获取IM接口前缀
export function getIMDetail () {
return request({
url: `${commonUrl}/common/IM`,
method: Method.GET
});
}

View File

@ -224,7 +224,7 @@ export default {
count: 1, // count: 1, //
imgIndex: 0, // imgIndex: 0, //
currentSelceted: [], // sku currentSelceted: [], // sku
imgList: [{}], // imgList: [{url:''}], //
skuDetail: this.detail.data, // sku skuDetail: this.detail.data, // sku
goodsSpecList: this.detail.specs, // spec goodsSpecList: this.detail.specs, // spec
promotionMap: { promotionMap: {

View File

@ -13,14 +13,24 @@
</BreadcrumbItem> </BreadcrumbItem>
</Breadcrumb> </Breadcrumb>
<div class="store-collect"> <div class="store-collect">
<span class="mr_10" v-if="goodsMsg.data"><router-link <span class="mr_10" v-if="goodsMsg.data">
:to="'Merchant?id=' + goodsMsg.data.storeId">{{ goodsMsg.data.storeName }}</router-link></span>
<span @click="collect"><Icon type="ios-heart" <router-link :to="'Merchant?id=' + goodsMsg.data.storeId">{{ goodsMsg.data.storeName }}</router-link>
:color="storeCollected ? '#ed3f14' : '#666'"/> </span>
{{storeCollected ? '已收藏店铺' : '收藏店铺'}} <span @click="collect">
</span> <Icon type="ios-heart" :color="storeCollected ? '#ed3f14' : '#666'" />
<span @click="connectCs(storeMsg.yzfSign)" class="ml_10"><Icon {{storeCollected ? '已收藏店铺' : '收藏店铺'}}
custom="icomoon icon-customer-service"/>联系客服</span> </span>
<!--
先看下udesk merchantEuid 是否有值
有的话 链接udesk
没有的话 显示云智服
-->
<span class="ml_10" v-if="storeMsg.merchantEuid" @click="IMService()"></span>
<span v-else @click="connectCs(storeMsg.yzfSign)" class="ml_10">
<Icon custom="icomoon icon-customer-service" />联系客服
</span>
</div> </div>
</div> </div>
</div> </div>
@ -35,128 +45,158 @@
</template> </template>
<script> <script>
import Search from '@/components/Search'; import Search from "@/components/Search";
import ShopHeader from '@/components/header/ShopHeader'; import ShopHeader from "@/components/header/ShopHeader";
import ShowGoods from '@/components/goodsDetail/ShowGoods'; import ShowGoods from "@/components/goodsDetail/ShowGoods";
import ShowGoodsDetail from '@/components/goodsDetail/ShowGoodsDetail'; import ShowGoodsDetail from "@/components/goodsDetail/ShowGoodsDetail";
import {goodsSkuDetail} from '@/api/goods'; import { goodsSkuDetail } from "@/api/goods";
import {cancelCollect, collectGoods, isCollection, getGoodsDistribution} from '@/api/member'; import {
import {getDetailById} from '@/api/shopentry' cancelCollect,
collectGoods,
isCollection,
getGoodsDistribution,
} from "@/api/member";
import { getDetailById } from "@/api/shopentry";
import { getIMDetail } from "@/api/common";
export default { export default {
name: 'GoodsDetail', name: "GoodsDetail",
beforeRouteEnter (to, from, next) { beforeRouteEnter(to, from, next) {
window.scrollTo(0, 0); window.scrollTo(0, 0);
next(); next();
}, },
created () { created() {
this.getGoodsDetail(); this.getGoodsDetail();
this.getIMDetailMethods();
}, },
data () { data() {
return { return {
goodsMsg: {}, // goodsMsg: {}, //
isLoading: false, // isLoading: false, //
categoryBar: [], // categoryBar: [], //
storeCollected: false, // storeCollected: false, //
storeMsg: {} // storeMsg: {}, //
IMLink: "",
}; };
}, },
methods: { methods: {
// im
IMService() {
window.open(this.IM);
},
// im
async getIMDetailMethods() {
let res = await getIMDetail();
if (res.success) {
this.IMLink = res.result;
}
},
// //
getGoodsDetail () { getGoodsDetail() {
this.isLoading = true; this.isLoading = true;
const params = this.$route.query; const params = this.$route.query;
// id // id
let distributionId = (params && params.distributionId) ? params.distributionId : this.Cookies.getItem('distributionId'); let distributionId =
params && params.distributionId
? params.distributionId
: this.Cookies.getItem("distributionId");
// //
if (distributionId) { if (distributionId) {
console.log(distributionId) console.log(distributionId);
// //
this.Cookies.setItem('distributionId', params.distributionId) this.Cookies.setItem("distributionId", params.distributionId);
let _this = this; let _this = this;
// //
getGoodsDistribution(params.distributionId).then(res => { getGoodsDistribution(params.distributionId).then((res) => {
// //
if (res.success) { if (res.success) {
_this.Cookies.removeItem('distributionId'); _this.Cookies.removeItem("distributionId");
} }
}) });
} }
goodsSkuDetail(params).then((res) => { goodsSkuDetail(params)
this.isLoading = false; .then((res) => {
if (res.success) { this.isLoading = false;
const result = res.result; if (res.success) {
const cateName = res.result.categoryName; const result = res.result;
const cateId = result.data.categoryPath.split(','); const cateName = res.result.categoryName;
const cateArr = []; const cateId = result.data.categoryPath.split(",");
cateId.forEach((e, index) => { // idname const cateArr = [];
cateArr.push({ cateId.forEach((e, index) => {
id: e, // idname
name: cateName[index] cateArr.push({
id: e,
name: cateName[index],
});
}); });
}); this.categoryBar = cateArr;
this.categoryBar = cateArr; this.goodsMsg = res.result;
this.goodsMsg = res.result; //
// if (this.Cookies.getItem("userInfo")) {
if (this.Cookies.getItem('userInfo')) { isCollection("STORE", this.goodsMsg.data.storeId).then((res) => {
isCollection('STORE', this.goodsMsg.data.storeId).then(res => { if (res.success && res.result) {
if (res.success && res.result) { this.storeCollected = true;
this.storeCollected = true; }
} });
})
}
//
getDetailById(this.goodsMsg.data.storeId).then(res => {
if (res.success) {
this.storeMsg = res.result
} }
}) //
} else { getDetailById(this.goodsMsg.data.storeId).then((res) => {
this.$Message.error(res.message) if (res.success) {
this.$router.push('/') this.storeMsg = res.result;
} }
}).catch(() => { });
this.$router.push('/') } else {
}); this.$Message.error(res.message);
this.$router.push("/");
}
})
.catch(() => {
this.$router.push("/");
});
}, },
goGoodsList (currIndex) { // goGoodsList(currIndex) {
const arr = [] //
const arr = [];
this.categoryBar.forEach((e, index) => { this.categoryBar.forEach((e, index) => {
if (index <= currIndex) { if (index <= currIndex) {
arr.push(e.id) arr.push(e.id);
} }
}) });
return location.origin + '/goodsList?categoryId=' + arr.toString() return location.origin + "/goodsList?categoryId=" + arr.toString();
}, },
async collect () { // async collect() {
//
if (this.storeCollected) { if (this.storeCollected) {
let cancel = await cancelCollect('STORE', this.goodsMsg.data.storeId) let cancel = await cancelCollect("STORE", this.goodsMsg.data.storeId);
if (cancel.success) { if (cancel.success) {
this.$Message.success('已取消收藏') this.$Message.success("已取消收藏");
this.storeCollected = false; this.storeCollected = false;
} }
} else { } else {
let collect = await collectGoods('STORE', this.goodsMsg.data.storeId); let collect = await collectGoods("STORE", this.goodsMsg.data.storeId);
if (collect.code === 200) { if (collect.code === 200) {
this.storeCollected = true; this.storeCollected = true;
this.$Message.success('收藏店铺成功,可以前往个人中心我的收藏查看'); this.$Message.success("收藏店铺成功,可以前往个人中心我的收藏查看");
} }
} }
} },
}, },
watch: { watch: {
'$route.query.skuId': function (val) { "$route.query.skuId": function (val) {
location.reload(); location.reload();
} },
},
computed: {
IM() {
return this.IMLink + this.storeMsg.merchantEuid;
},
}, },
computed: {},
components: { components: {
Search, Search,
ShopHeader, ShopHeader,
ShowGoods, ShowGoods,
ShowGoodsDetail ShowGoodsDetail,
} },
}; };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">