master
2022-12-27 14:49:23 +08:00
parent 5e38247ce8
commit 18251dde89
3 changed files with 590 additions and 687 deletions

View File

@ -64,4 +64,11 @@ export function getTalk(talkId) {
params params
}); });
} }
// 从商品页点击 客服 跳转 获取聊天记录
export function jumpObtain(skuId, goodsId) {
return http.request({
url: `${api.im}/goods/goods/sku/${goodsId}/${skuId}`,
method: Method.GET,
});
}

View File

@ -1,102 +1,100 @@
<template> <template>
<view> <view>
<u-navbar class="my-title" title-size="32" back-text="" :title="toUser.name"></u-navbar> <u-navbar class="my-title" title-size="32" back-text="" :title="toUser.name"></u-navbar>
<!-- 空盒子用来防止消息过少时 拉起键盘会遮盖消息 --> <!-- 空盒子用来防止消息过少时 拉起键盘会遮盖消息 -->
<view :animation="anData" style="height:0;"> <view :animation="anData" style="height:0;">
</view> </view>
<!-- 消息体 --> <!-- 消息体 -->
<!-- 用来获取消息体高度 --> <!-- 用来获取消息体高度 -->
<view id="msgList"> <view id="msgList">
<!-- 消息 --> <!-- 消息 -->
<view class="flex-column-start" v-for="(item, index) in msgList" :key="index"> <view class="flex-column-start" v-for="(item, index) in msgList" :key="index">
<view class="flex-row-start column-time"> <view class="flex-row-start column-time">
<view v-show="compareTime(index, item.createTime)" class="flex-row-start date-text" <view v-show="compareTime(index, item.createTime)" class="flex-row-start date-text"
v-text="beautifyTime(item.createTime)"> v-text="beautifyTime(item.createTime)">
</view> </view>
</view> </view>
<!-- 用户消息 头像可选加入--> <!-- 用户消息 头像可选加入-->
<view v-if="item.my" class="flex justify-end padding-right one-show align-start padding-top"> <view v-if="item.my" class="flex justify-end padding-right one-show align-start padding-top">
<!-- <image class="chat-img flex-row-center" :src="'https://ikeeppet.oss-cn-zhangjiakou.aliyuncs.com/028b7818b78c47ef8f87a7faa1098faf.jpg'" mode="aspectFill" ></image> --> <!-- <image class="chat-img flex-row-center" :src="'https://ikeeppet.oss-cn-zhangjiakou.aliyuncs.com/028b7818b78c47ef8f87a7faa1098faf.jpg'" mode="aspectFill" ></image> -->
<view class="flex justify-end" style="width: 400rpx;margin-top: 12px;"> <view class="flex justify-end" style="width: 400rpx;margin-top: 12px;">
<view> <view>
<view class="user-name">{{ user.nickName }}</view> <view class="user-name">{{ user.nickName }}</view>
<view class="margin-left padding-chat bg-user-orang" style="border-radius: 35rpx;"> <view class="margin-left padding-chat bg-user-orang" style="border-radius: 35rpx;">
<text style="word-break: break-all;">{{ item.text }}</text> <text style="word-break: break-all;">{{ item.text }}</text>
</view> </view>
</view> </view>
</view> </view>
<view> <view>
<u-avatar :src="user.face" :text="user.face ? '' : user.name" bg-color="#DDDDDD"></u-avatar> <u-avatar :src="user.face" :text="user.face ? '' : user.name" bg-color="#DDDDDD"></u-avatar>
<!-- <u-image class="chat-img margin-left" style="height: 100rpx;width: 100rpx;" shape="circle" <!-- <u-image class="chat-img margin-left" style="height: 100rpx;width: 100rpx;" shape="circle"
:src="user.face || 'https://avatars.dicebear.com/api/initials/' + user.nickName + '.svg?fontSize=38'" :src="user.face || 'https://avatars.dicebear.com/api/initials/' + user.nickName + '.svg?fontSize=38'"
mode="aspectFill"></u-image> --> mode="aspectFill"></u-image> -->
</view> </view>
</view> </view>
<!-- 接收人消息 --> <!-- 接收人消息 -->
<view v-else class="flex-row-start margin-left margin-top one-show"> <view v-else class="flex-row-start margin-left margin-top one-show">
<view class="chat-img flex-row-center"> <view class="chat-img flex-row-center">
<u-avatar :src="toUser.face" :text="toUser.face ? '' : toUser.name" <u-avatar :src="toUser.face" :text="toUser.face ? '' : toUser.name" bg-color="#DDDDDD"></u-avatar>
bg-color="#DDDDDD"></u-avatar> <!-- <u-image style="height: 100rpx;width: 100rpx;" shape="circle"
<!-- <u-image style="height: 100rpx;width: 100rpx;" shape="circle"
:src="toUser.face || 'https://avatars.dicebear.com/api/initials/' + toUser.name + '.svg?fontSize=38'" :src="toUser.face || 'https://avatars.dicebear.com/api/initials/' + toUser.name + '.svg?fontSize=38'"
mode="aspectFit"></u-image> --> mode="aspectFit"></u-image> -->
</view> </view>
<view class="flex" style="width: 500rpx;"> <view class="flex" style="width: 500rpx;">
<view> <view>
<view class="other-name">{{ toUser.name }}</view> <view class="other-name">{{ toUser.name }}</view>
<view class="margin-left padding-chat flex-column-start bg-to-color" <view class="margin-left padding-chat flex-column-start bg-to-color" style="border-radius: 35rpx;">
style="border-radius: 35rpx;"> <text style="word-break: break-all;">{{ item.text }}</text>
<text style="word-break: break-all;">{{ item.text }}</text> </view>
</view> </view>
</view>
</view> </view>
</view> </view>
</view> </view>
<!-- loading是显示 --> <!-- loading是显示 -->
<view v-show="msgLoad" class="flex-row-start margin-left margin-top"> <view v-show="msgLoad" class="flex-row-start margin-left margin-top">
<view class="chat-img flex-row-center"> <view class="chat-img flex-row-center">
<!-- <image style="height: 75rpx;width: 75rpx;" src="../../static/image/robt.png" mode="aspectFit"></image> --> <!-- <image style="height: 75rpx;width: 75rpx;" src="../../static/image/robt.png" mode="aspectFit"></image> -->
</view> </view>
<view class="flex" style="width: 500rpx;"> <view class="flex" style="width: 500rpx;">
<view class="margin-left padding-chat flex-column-start" <view class="margin-left padding-chat flex-column-start"
style="border-radius: 35rpx;background-color: #f9f9f9;"> style="border-radius: 35rpx;background-color: #f9f9f9;">
<view class="cuIcon-loading turn-load" style="font-size: 35rpx;color: #3e9982;"> <view class="cuIcon-loading turn-load" style="font-size: 35rpx;color: #3e9982;">
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<!-- 防止消息底部被遮 --> <!-- 防止消息底部被遮 -->
<view style="height: 120rpx;"> <view style="height: 120rpx;">
</view> </view>
</view> </view>
<!-- 底部导航栏 --> <!-- 底部导航栏 -->
<view class="flex-column-center" style="position: fixed;bottom: -180px;" :animation="animationData"> <view class="flex-column-center" style="position: fixed;bottom: -180px;" :animation="animationData">
<view class="bottom-dh-char flex-row-around" style="font-size: 55rpx;"> <view class="bottom-dh-char flex-row-around" style="font-size: 55rpx;">
<!-- vue无法使用软键盘"发送" --> <!-- vue无法使用软键盘"发送" -->
<input v-model="msg" class="dh-input" type="text" style="background-color: #f0f0f0;" @confirm="sendMsg" <input v-model="msg" class="dh-input" type="text" style="background-color: #f0f0f0;" @confirm="sendMsg"
confirm-type="search" placeholder-class="my-neirong-sm" placeholder="用一句简短的话描述您的问题" /> confirm-type="search" placeholder-class="my-neirong-sm" placeholder="用一句简短的话描述您的问题" />
<view @click="sendMsg" class="cu-tag bg-cyan round"> <view @click="sendMsg" class="cu-tag bg-cyan round">
发送 发送
</view> </view>
<!-- <text @click="ckAdd" class="cuIcon-roundaddfill text-brown"></text> --> <!-- <text @click="ckAdd" class="cuIcon-roundaddfill text-brown"></text> -->
</view> </view>
<!-- 附加栏(自定义) --> <!-- 附加栏(自定义) -->
<view class="box-normal flex-row-around flex-wrap"> <view class="box-normal flex-row-around flex-wrap">
<view class="tb-text"> <view class="tb-text">
<view class="cuIcon-form"></view> <view class="cuIcon-form"></view>
<text>问题反馈</text> <text>问题反馈</text>
</view> </view>
<view class="tb-text"> <view class="tb-text">
<view class="cuIcon-form"></view> <view class="cuIcon-form"></view>
<text>人工客服</text> <text>人工客服</text>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
@ -106,422 +104,422 @@ var l
var wh var wh
// //
var mgUpHeight var mgUpHeight
import { getTalkMessage, getTalkByUser } from "@/api/im.js"; import { getTalkMessage, getTalkByUser, jumpObtain } from "@/api/im.js";
import SocketService from "@/utils/socket_service.js"; import SocketService from "@/utils/socket_service.js";
import storage from "@/utils/storage.js"; import storage from "@/utils/storage.js";
import { beautifyTime } from "@/utils/filters.js" import { beautifyTime } from "@/utils/filters.js"
export default { export default {
onLoad(options) { onLoad (options) {
// msgList // msgList
// //
// , // ,
uni.onKeyboardHeightChange(res => { uni.onKeyboardHeightChange(res => {
const query = uni.createSelectorQuery() const query = uni.createSelectorQuery()
query.select('#msgList').boundingClientRect(data => { query.select('#msgList').boundingClientRect(data => {
// 2, // 2,
var up = res.height * 2 - data.height - l * 110 var up = res.height * 2 - data.height - l * 110
console.log(up) console.log(up)
if (up > 0) { if (up > 0) {
// //
this.msgMove(up, 300) this.msgMove(up, 300)
// , // ,
mgUpHeight = up mgUpHeight = up
} }
// //
if (res.height == 0) { if (res.height == 0) {
this.msgMove(0, 0) this.msgMove(0, 0)
} }
}).exec(); }).exec();
}) })
var query = uni.getSystemInfoSync() var query = uni.getSystemInfoSync()
l = query.screenWidth / 750 l = query.screenWidth / 750
wh = query.windowHeight wh = query.windowHeight
this.srcollHeight = (query.windowHeight - 44) + "px" this.srcollHeight = (query.windowHeight - 44) + "px"
this.user = storage.getUserInfo() this.user = storage.getUserInfo()
this.toUser = storage.getTalkToUser() this.toUser = storage.getTalkToUser()
if (options.talkId) { if (options.talkId) {
this.params.talkId = options.talkId; this.params.talkId = options.talkId;
this.getTalkMessage() this.getTalkMessage()
} else { } else {
this.getTalk(options.userId) this.getTalk(options.userId)
} }
this.ws.connect(); this.ws.connect();
}, },
onPullDownRefresh() { onPullDownRefresh () {
this.params.pageNumber = this.params.pageNumber + 1 this.params.pageNumber = this.params.pageNumber + 1
this.getTalkMessage() this.getTalkMessage()
console.log('下拉事件'); console.log('下拉事件');
setTimeout(function () { setTimeout(function () {
uni.stopPullDownRefresh(); uni.stopPullDownRefresh();
}, 1000); }, 1000);
}, },
components: { components: {
beautifyTime beautifyTime
}, },
data() { data () {
return { return {
msgLoad: false, msgLoad: false,
anData: {}, anData: {},
animationData: {}, animationData: {},
msgList: [], msgList: [],
oldHeight: 0, oldHeight: 0,
params: { // params: { //
talkId: '', talkId: '',
pageSize: 10, pageSize: 10,
pageNumber: 1, pageNumber: 1,
}, },
goToIndex: 0, // goToIndex: 0, //
msg: "", msg: "",
go: 0, go: 0,
newMessageNum: 0, newMessageNum: 0,
user: {}, user: {},
toUser: {}, toUser: {},
srcollHeight: 0, srcollHeight: 0,
ws: new SocketService(), ws: new SocketService(),
} }
}, },
watch: { watch: {
'ws.callBackMapping': { 'ws.callBackMapping': {
handler: function (val) { handler: function (val) {
val = JSON.parse(val) val = JSON.parse(val)
if (val.messageResultType == 'MESSAGE') { if (val.messageResultType == 'MESSAGE') {
this.msgList.push(val.result) this.msgList.push(val.result)
} }
this.newMessageNum++; this.newMessageNum++;
console.log(this.msgList) console.log(this.msgList)
// //
let msg = val let msg = val
msg.operation_type = 'READ' msg.operation_type = 'READ'
this.ws.send(JSON.stringify(msg)) this.ws.send(JSON.stringify(msg))
} }
} }
}, },
methods: { methods: {
beautifyTime, beautifyTime,
// (-->bug) // (-->bug)
goPag(kh) { goPag (kh) {
this.upTowmn(0, 250) this.upTowmn(0, 250)
if (this.keyHeight != 0) { if (this.keyHeight != 0) {
if (kh - this.keyHeight > 0) { if (kh - this.keyHeight > 0) {
this.upTowmn(this.keyHeight - kh, 250) this.upTowmn(this.keyHeight - kh, 250)
} }
} }
}, },
// //
msgMove(x, t) { msgMove (x, t) {
var animation = uni.createAnimation({ var animation = uni.createAnimation({
duration: t, duration: t,
timingFunction: 'linear', timingFunction: 'linear',
}) })
this.animation = animation this.animation = animation
animation.height(x).step() animation.height(x).step()
this.anData = animation.export() this.anData = animation.export()
}, },
// //
msgGo(type) { msgGo (type) {
const query = uni.createSelectorQuery() const query = uni.createSelectorQuery()
// 100ms // 100ms
setTimeout(() => { setTimeout(() => {
// //
query.select('#msgList').boundingClientRect(data => { query.select('#msgList').boundingClientRect(data => {
// scorllscorll // scorllscorll
if (type == 'up') { if (type == 'up') {
this.go = data.height - this.oldHeight this.go = data.height - this.oldHeight
} else if (type == 'down') { } else if (type == 'down') {
this.go = data.height - wh + 120 this.go = data.height - wh + 120
} }
// if (this.oldHeight > 0) { // if (this.oldHeight > 0) {
// this.go = data.height - this.oldHeight // this.go = data.height - this.oldHeight
// } else { // } else {
// // if (data.height - (wh - 32) > 0) { // // if (data.height - (wh - 32) > 0) {
// this.go = data.height - wh + 120 // this.go = data.height - wh + 120
// } // }
// //
var moveY = wh - data.height var moveY = wh - data.height
// //
if (moveY - mgUpHeight < 0) { if (moveY - mgUpHeight < 0) {
// 00 // 00
if (moveY < 0) { if (moveY < 0) {
this.msgMove(0, 200) this.msgMove(0, 200)
} else { } else {
// //
this.msgMove(moveY, 200) this.msgMove(moveY, 200)
} }
} }
uni.pageScrollTo({ uni.pageScrollTo({
scrollTop: this.go, scrollTop: this.go,
duration: 0 duration: 0
}) })
this.oldHeight = data.height this.oldHeight = data.height
}).exec(); }).exec();
}, 100) }, 100)
}, },
// //
answer(id) { answer (id) {
// id,index // id,index
console.log(id) console.log(id)
}, },
sendMsg() { sendMsg () {
console.log("发送") console.log("发送")
// //
if (this.msg == "") { if (this.msg == "") {
return 0; return 0;
} }
// msg,my(,穿) // msg,my(,穿)
let msg = { let msg = {
operation_type: "MESSAGE", operation_type: "MESSAGE",
to: this.toUser.userId, to: this.toUser.userId,
from: this.user.id, from: this.user.id,
message_type: "MESSAGE", message_type: "MESSAGE",
context: this.msg, context: this.msg,
talk_id: this.params.talkId, talk_id: this.params.talkId,
} }
this.ws.send(JSON.stringify(msg)) this.ws.send(JSON.stringify(msg))
this.msgList.push({ "text": this.msg, "my": true }) this.msgList.push({ "text": this.msg, "my": true })
// //
let type = 'down'; let type = 'down';
this.msgGo(type) this.msgGo(type)
// //
// this.msgKf(this.msg) // this.msgKf(this.msg)
// //
this.msg = "" this.msg = ""
}, },
// msgKf(x) { // msgKf(x) {
// // loading // // loading
// // this.msgLoad = true // // this.msgLoad = true
// // // //
// // // //
// // setTimeout(() => { // // setTimeout(() => {
// // // loading // // // loading
// // this.msgLoad = false // // this.msgLoad = false
// // // this.msgGo() // // // this.msgGo()
// // }, 2000) // // }, 2000)
// }, // },
// //
ckAdd() { ckAdd () {
if (!this.showTow) { if (!this.showTow) {
this.upTowmn(-180, 350) this.upTowmn(-180, 350)
} else { } else {
this.upTowmn(0, 200) this.upTowmn(0, 200)
} }
this.showTow = !this.showTow this.showTow = !this.showTow
}, },
hideKey() { hideKey () {
uni.hideKeyboard() uni.hideKeyboard()
}, },
// / // /
upTowmn(x, t) { upTowmn (x, t) {
var animation = uni.createAnimation({ var animation = uni.createAnimation({
duration: t, duration: t,
timingFunction: 'ease', timingFunction: 'ease',
}) })
this.animation = animation this.animation = animation
animation.translateY(x).step() animation.translateY(x).step()
this.animationData = animation.export() this.animationData = animation.export()
}, },
async getTalkMessage() { async getTalkMessage () {
let type = ''; let type = '';
await getTalkMessage(this.params).then(res => { await getTalkMessage(this.params).then(res => {
if (res.data.success) { if (res.data.success) {
if (this.msgList.length >= 10) { if (this.msgList.length >= 10) {
this.msgList.unshift(...res.data.result) this.msgList.unshift(...res.data.result)
type = 'up' type = 'up'
} else { } else {
this.msgList = res.data.result this.msgList = res.data.result
type = 'down' type = 'down'
} }
this.msgList.forEach(item => { this.msgList.forEach(item => {
if (item.fromUser === this.user.id) { if (item.fromUser === this.user.id) {
item.my = true item.my = true
} }
}) })
} }
}) })
this.msgGo(type) this.msgGo(type)
}, },
touchmovemsg(e) { touchmovemsg (e) {
if (e.target.scrollTop == 0) { if (e.target.scrollTop == 0) {
this.params.pageNumber = this.params.pageNumber + 1 this.params.pageNumber = this.params.pageNumber + 1
this.getTalkMessage() this.getTalkMessage()
} }
}, },
async getTalk(userId) { async getTalk (userId) {
getTalkByUser(userId).then(res => { getTalkByUser(userId).then(res => {
if (res.data.success) { if (res.data.success) {
this.toUser = res.data.result this.toUser = res.data.result
this.params.talkId = res.data.result.id this.params.talkId = res.data.result.id
} }
}) })
}, },
// //
compareTime(index, datetime) { compareTime (index, datetime) {
if (datetime == undefined) { if (datetime == undefined) {
return false; return false;
} }
if (typeof datetime == "number") { if (typeof datetime == "number") {
datetime = this.unixToDate(datetime, "yyyy-MM-dd hh:mm"); datetime = this.unixToDate(datetime, "yyyy-MM-dd hh:mm");
} }
if (this.msgList[index].is_revoke == 1) { if (this.msgList[index].is_revoke == 1) {
return false; return false;
} }
datetime = datetime.replace(/-/g, "/"); datetime = datetime.replace(/-/g, "/");
let time = Math.floor(Date.parse(datetime) / 1000); let time = Math.floor(Date.parse(datetime) / 1000);
let currTime = Math.floor(new Date().getTime() / 1000); let currTime = Math.floor(new Date().getTime() / 1000);
// 5 // 5
if (currTime - time < 300) return false; if (currTime - time < 300) return false;
// , // ,
if (index == this.msgList.length - 1) { if (index == this.msgList.length - 1) {
return true; return true;
} }
let nextDate let nextDate
if (this.msgList[index + 1]) { if (this.msgList[index + 1]) {
nextDate = this.msgList[index + 1].createTime.replace(/-/g, "/"); nextDate = this.msgList[index + 1].createTime.replace(/-/g, "/");
if (nextDate - datetime < 300) return false; if (nextDate - datetime < 300) return false;
} }
return !( return !(
this.unixToDate(new Date(datetime), "{y}-{m}-{d} {h}:{i}") == this.unixToDate(new Date(datetime), "{y}-{m}-{d} {h}:{i}") ==
this.unixToDate(new Date(nextDate), "{y}-{m}-{d} {h}:{i}") this.unixToDate(new Date(nextDate), "{y}-{m}-{d} {h}:{i}")
); );
}, },
/** /**
* 将unix时间戳转换为指定格式 * 将unix时间戳转换为指定格式
* @param unix 时间戳 * @param unix 时间戳
* @param format 转换格式 * @param format 转换格式
* @returns {*|string} * @returns {*|string}
*/ */
unixToDate(unix, format) { unixToDate (unix, format) {
if (!unix) return unix; if (!unix) return unix;
let _format = format || "yyyy-MM-dd hh:mm:ss"; let _format = format || "yyyy-MM-dd hh:mm:ss";
const d = new Date(unix); const d = new Date(unix);
const o = { const o = {
"M+": d.getMonth() + 1, "M+": d.getMonth() + 1,
"d+": d.getDate(), "d+": d.getDate(),
"h+": d.getHours(), "h+": d.getHours(),
"m+": d.getMinutes(), "m+": d.getMinutes(),
"s+": d.getSeconds(), "s+": d.getSeconds(),
"q+": Math.floor((d.getMonth() + 3) / 3), "q+": Math.floor((d.getMonth() + 3) / 3),
S: d.getMilliseconds(), S: d.getMilliseconds(),
}; };
if (/(y+)/.test(_format)) if (/(y+)/.test(_format))
_format = _format.replace( _format = _format.replace(
RegExp.$1, RegExp.$1,
(d.getFullYear() + "").substr(4 - RegExp.$1.length) (d.getFullYear() + "").substr(4 - RegExp.$1.length)
); );
for (const k in o) for (const k in o)
if (new RegExp("(" + k + ")").test(_format)) if (new RegExp("(" + k + ")").test(_format))
_format = _format.replace( _format = _format.replace(
RegExp.$1, RegExp.$1,
RegExp.$1.length === 1 RegExp.$1.length === 1
? o[k] ? o[k]
: ("00" + o[k]).substr(("" + o[k]).length) : ("00" + o[k]).substr(("" + o[k]).length)
); );
return _format; return _format;
}, },
} }
} }
</script> </script>
<style> <style>
.bottom-dh-char { .bottom-dh-char {
background-color: #f9f9f9; background-color: #f9f9f9;
width: 750rpx; width: 750rpx;
height: 110rpx; height: 110rpx;
} }
.user-name { .user-name {
text-align: right; text-align: right;
font-size: 24rpx; font-size: 24rpx;
color: #737373; color: #737373;
margin-bottom: 10rpx; margin-bottom: 10rpx;
margin-right: 10rpx; margin-right: 10rpx;
} }
.other-name { .other-name {
text-align: left; text-align: left;
font-size: 24rpx; font-size: 24rpx;
color: #737373; color: #737373;
margin-bottom: 10rpx; margin-bottom: 10rpx;
margin-left: 10rpx; margin-left: 10rpx;
} }
.column-time { .column-time {
justify-content: center; justify-content: center;
} }
.center-box { .center-box {
width: 720rpx; width: 720rpx;
padding-left: 25rpx; padding-left: 25rpx;
} }
.hui-box { .hui-box {
width: 750rpx; width: 750rpx;
height: 100%; height: 100%;
} }
.date-text { .date-text {
font-size: 12px; font-size: 12px;
color: grey; color: grey;
} }
.dh-input { .dh-input {
width: 500rpx; width: 500rpx;
height: 65rpx; height: 65rpx;
border-radius: 30rpx; border-radius: 30rpx;
padding-left: 15rpx; padding-left: 15rpx;
font-size: 35rpx; font-size: 35rpx;
background-color: #FFFFFF; background-color: #FFFFFF;
} }
.box-normal { .box-normal {
width: 750rpx; width: 750rpx;
height: 180px; height: 180px;
background-color: #FFFFFF; background-color: #FFFFFF;
} }
.tb-text view { .tb-text view {
font-size: 65rpx; font-size: 65rpx;
} }
.tb-text text { .tb-text text {
font-size: 25rpx; font-size: 25rpx;
color: #737373; color: #737373;
} }
.chat-img { .chat-img {
border-radius: 50%; border-radius: 50%;
width: 100rpx; width: 100rpx;
height: 100rpx; height: 100rpx;
background-color: #f7f7f7; background-color: #f7f7f7;
} }
.padding-chat { .padding-chat {
padding: 17rpx 20rpx; padding: 17rpx 20rpx;
} }
.tb-nv { .tb-nv {
width: 50rpx; width: 50rpx;
height: 50rpx; height: 50rpx;
} }
</style> </style>

View File

@ -6,55 +6,27 @@
<!-- 仅h5有效 打开App --> <!-- 仅h5有效 打开App -->
<!-- 分享 --> <!-- 分享 -->
<shares <shares v-if="enableShare && goodsDetail.id" :skuId="this.routerVal.id" :goodsId="this.routerVal.goodsId" :link="
v-if="enableShare && goodsDetail.id" '/pages/product/goods?id=' +
:skuId="this.routerVal.id" this.routerVal.id +
:goodsId="this.routerVal.goodsId" '&goodsId=' +
:link=" this.routerVal.goodsId
'/pages/product/goods?id=' + " :thumbnail="goodsDetail.thumbnail" :goodsName="goodsDetail.goodsName" type="goods" @close="enableShare = false" />
this.routerVal.id + <popups v-model="popupsSwitch" @tapPopup="handleNavbarList" :popData="navbarListData" :x="navbarListX"
'&goodsId=' + :y="navbarListY" placement="top-start" />
this.routerVal.goodsId
"
:thumbnail="goodsDetail.thumbnail"
:goodsName="goodsDetail.goodsName"
type="goods"
@close="enableShare = false"
/>
<popups
v-model="popupsSwitch"
@tapPopup="handleNavbarList"
:popData="navbarListData"
:x="navbarListX"
:y="navbarListY"
placement="top-start"
/>
<view class="index"> <view class="index">
<!-- topBar --> <!-- topBar -->
<u-navbar <u-navbar :background="navbar" :is-back="false" :class="headerFlag ? 'header' : 'header bg-none scroll-hide'">
:background="navbar"
:is-back="false"
:class="headerFlag ? 'header' : 'header bg-none scroll-hide'"
>
<div class="headerRow"> <div class="headerRow">
<div class="backs"> <div class="backs">
<u-icon @click="back()" name="arrow-left" class="icon-back"></u-icon> <u-icon @click="back()" name="arrow-left" class="icon-back"></u-icon>
<u-icon <u-icon name="list" @click="popupsSwitch = !popupsSwitch" class="icon-list"></u-icon>
name="list"
@click="popupsSwitch = !popupsSwitch"
class="icon-list"
></u-icon>
</div> </div>
<div class="headerList" :class="headerFlag ? 'tab-bar' : 'tab-bar scroll-hide'"> <div class="headerList" :class="headerFlag ? 'tab-bar' : 'tab-bar scroll-hide'">
<div class="headerRow"> <div class="headerRow">
<div <div class="nav-item" v-for="header in headerList" :key="header.id"
class="nav-item" :class="{ cur: scrollId === header.id }" @click="headerTab(header.id)">
v-for="header in headerList"
:key="header.id"
:class="{ cur: scrollId === header.id }"
@click="headerTab(header.id)"
>
{{ header.text }} {{ header.text }}
</div> </div>
</div> </div>
@ -62,57 +34,26 @@
</div> </div>
</u-navbar> </u-navbar>
<u-navbar <u-navbar :border-bottom="false" v-show="!headerFlag" class="header-only-back" :background="navbarOnlyBack"
:border-bottom="false" :is-back="false">
v-show="!headerFlag"
class="header-only-back"
:background="navbarOnlyBack"
:is-back="false"
>
<div> <div>
<div class="bg-back"> <div class="bg-back">
<u-icon <u-icon size="40" @click="back()" name="arrow-left" class="icon-back"></u-icon>
size="40" <u-icon size="40" @click="popupsSwitch = !popupsSwitch" name="list" class="icon-list"></u-icon>
@click="back()"
name="arrow-left"
class="icon-back"
></u-icon>
<u-icon
size="40"
@click="popupsSwitch = !popupsSwitch"
name="list"
class="icon-list"
></u-icon>
</div> </div>
</div> </div>
</u-navbar> </u-navbar>
</view> </view>
<view <view class="product-container" :style="{ height: productRefHeight }" ref="productRef" id="productRef">
class="product-container" <scroll-view scroll-anchoring enableBackToTop="true" scroll-with-animation scroll-y class="scroll-page"
:style="{ height: productRefHeight }" :scroll-top="tabScrollTop" @scroll="pageScroll">
ref="productRef"
id="productRef"
>
<scroll-view
scroll-anchoring
enableBackToTop="true"
scroll-with-animation
scroll-y
class="scroll-page"
:scroll-top="tabScrollTop"
@scroll="pageScroll"
>
<view> <view>
<!-- 轮播图 --> <!-- 轮播图 -->
<GoodsSwiper id="main1" :res="imgList" /> <GoodsSwiper id="main1" :res="imgList" />
<!-- 促销活动条 --> <!-- 促销活动条 -->
<PromotionAssembleLayout <PromotionAssembleLayout v-if="PromotionList" :detail="goodsDetail" :res="PromotionList" />
v-if="PromotionList"
:detail="goodsDetail"
:res="PromotionList"
/>
<view class="card-box top-radius-0" id="main2"> <view class="card-box top-radius-0" id="main2">
<!-- 活动不显示价钱 --> <!-- 活动不显示价钱 -->
@ -122,15 +63,11 @@
{{ goodsDetail.goodsName || "" }} {{ goodsDetail.goodsName || "" }}
</view> </view>
<view class="favorite" @click="clickFavorite(goodsDetail.id)"> <view class="favorite" @click="clickFavorite(goodsDetail.id)">
<u-icon <u-icon size="30" :color="favorite ? '#f2270c' : '#262626'" :name="favorite ? 'heart-fill' : 'heart'">
size="30"
:color="favorite ? '#f2270c' : '#262626'"
:name="favorite ? 'heart-fill' : 'heart'"
>
</u-icon> </u-icon>
<view :style="{ color: favorite ? '#f2270c' : '#262626' }">{{ <view :style="{ color: favorite ? '#f2270c' : '#262626' }">{{
favorite ? "已收藏" : "收藏" favorite ? "已收藏" : "收藏"
}}</view> }}</view>
</view> </view>
</view> </view>
<!-- 商品描述 --> <!-- 商品描述 -->
@ -144,16 +81,25 @@
<view class="-goods-flex"> <view class="-goods-flex">
<!-- 如果有积分显示积分 --> <!-- 如果有积分显示积分 -->
<view class="-goods-price" v-if="goodsDetail.price != undefined"> <view class="-goods-price" v-if="goodsDetail.price != undefined">
<span > <span>
<span v-if="wholesaleList.length"> <span v-if="wholesaleList.length">
<span>¥</span><span class="price">{{ $options.filters.goodsFormatPrice(wholesaleList[wholesaleList.length-1].price)[0] }}</span>.{{ $options.filters.goodsFormatPrice(wholesaleList[wholesaleList.length-1].price)[1] }} <span>¥</span><span class="price">{{
~ $options.filters.goodsFormatPrice(wholesaleList[wholesaleList.length - 1].price)[0]
<span>¥</span><span class="price">{{ $options.filters.goodsFormatPrice(wholesaleList[0].price)[0] }}</span>.{{ $options.filters.goodsFormatPrice(wholesaleList[0].price)[1] }} }}</span>.{{
</span> $options.filters.goodsFormatPrice(wholesaleList[wholesaleList.length - 1].price)[1]
<span v-else> }}
<span>¥</span><span class="price">{{ $options.filters.goodsFormatPrice(goodsDetail.price)[0] }}</span>.{{ $options.filters.goodsFormatPrice(goodsDetail.price)[1] }} ~
</span> <span>¥</span><span class="price">{{
$options.filters.goodsFormatPrice(wholesaleList[0].price)[0]
}}</span>.{{
$options.filters.goodsFormatPrice(wholesaleList[0].price)[1]
}}
</span>
<span v-else>
<span>¥</span><span class="price">{{ $options.filters.goodsFormatPrice(goodsDetail.price)[0]
}}</span>.{{ $options.filters.goodsFormatPrice(goodsDetail.price)[1] }}
</span>
</span> </span>
</view> </view>
<view class="-goods-price" v-else> <view class="-goods-price" v-else>
@ -165,14 +111,11 @@
<view>分享</view> <view>分享</view>
</view> </view>
<view class="icons" @click="clickFavorite(goodsDetail.id)"> <view class="icons" @click="clickFavorite(goodsDetail.id)">
<u-icon <u-icon size="30" :color="favorite ? '#f2270c' : '#262626'"
size="30" :name="favorite ? 'heart-fill' : 'heart'"></u-icon>
:color="favorite ? '#f2270c' : '#262626'"
:name="favorite ? 'heart-fill' : 'heart'"
></u-icon>
<view :style="{ color: favorite ? '#f2270c' : '#262626' }">{{ <view :style="{ color: favorite ? '#f2270c' : '#262626' }">{{
favorite ? "已收藏" : "收藏" favorite ? "已收藏" : "收藏"
}}</view> }}</view>
</view> </view>
</view> </view>
<view class="-goods-name desc-bold"> <view class="-goods-name desc-bold">
@ -199,22 +142,16 @@
</view> </view>
<!-- 拼团用户列表 --> <!-- 拼团用户列表 -->
<PromotionAssembleListLayout <PromotionAssembleListLayout v-if="isGroup" @to-assemble-buy-now="toAssembleBuyNow" :res="PromotionList" />
v-if="isGroup"
@to-assemble-buy-now="toAssembleBuyNow"
:res="PromotionList"
/>
<!-- 配置地址 如果是虚拟产品的时候不展示 --> <!-- 配置地址 如果是虚拟产品的时候不展示 -->
<view class="card-box" v-if="goodsDetail.goodsType != 'VIRTUAL_GOODS'"> <view class="card-box" v-if="goodsDetail.goodsType != 'VIRTUAL_GOODS'">
<view class="card-flex" @click="shutMask(4)"> <view class="card-flex" @click="shutMask(4)">
<view class="card-title"> 已选 </view> <view class="card-title"> 已选 </view>
<view class="card-content"> <view class="card-content">
<span v-if="selectedGoods.spec" <span v-if="selectedGoods.spec">{{ selectedGoods.spec.specName }}-{{
>{{ selectedGoods.spec.specName }}-{{ selectedGoods.spec.specValue
selectedGoods.spec.specValue }}</span>
}}</span
>
<span v-else></span> <span v-else></span>
</view> </view>
<view class="card-bottom"> <view class="card-bottom">
@ -225,8 +162,8 @@
<view class="card-title"> 送至</view> <view class="card-title"> 送至</view>
<view class="card-content"> <view class="card-content">
<span v-if="delivery">{{ <span v-if="delivery">{{
delivery.consigneeAddressPath | clearStrComma delivery.consigneeAddressPath | clearStrComma
}}</span> }}</span>
<span v-else></span> <span v-else></span>
</view> </view>
<view class="card-bottom"> <view class="card-bottom">
@ -239,21 +176,11 @@
<Evaluation id="main5" :goodsDetail="goodsDetail" /> <Evaluation id="main5" :goodsDetail="goodsDetail" />
<!-- 店铺推荐 --> <!-- 店铺推荐 -->
<storeLayout <storeLayout id="main7" :storeDetail="storeDetail" :goodsDetail="goodsDetail" :res="recommendList" />
id="main7"
:storeDetail="storeDetail"
:goodsDetail="goodsDetail"
:res="recommendList"
/>
<!-- 宝贝详情 --> <!-- 宝贝详情 -->
<GoodsIntro <GoodsIntro id="main9" :res="goodsDetail" :goodsParams="goodsParams" :goodsId="goodsDetail.goodsId"
id="main9" v-if="goodsDetail.id" />
:res="goodsDetail"
:goodsParams="goodsParams"
:goodsId="goodsDetail.goodsId"
v-if="goodsDetail.id"
/>
<!-- 宝贝推荐 --> <!-- 宝贝推荐 -->
<GoodsRecommend id="main11" :res="likeGoodsList" /> <GoodsRecommend id="main11" :res="likeGoodsList" />
@ -278,13 +205,8 @@
</view> </view>
<!-- 正常结算页面 --> <!-- 正常结算页面 -->
<view class="detail-btn" v-if="!isGroup"> <view class="detail-btn" v-if="!isGroup">
<view <view class="to-store-car to-store-btn" v-if="goodsDetail.goodsType != 'VIRTUAL_GOODS'" @click="shutMask(4)">
class="to-store-car to-store-btn" 加入购物车</view>
v-if="goodsDetail.goodsType != 'VIRTUAL_GOODS'"
@click="shutMask(4)"
>
加入购物车</view
>
<view class="to-buy to-store-btn" @click="shutMask(4, 'buy')">立即购买</view> <view class="to-buy to-store-btn" @click="shutMask(4, 'buy')">立即购买</view>
<view class="to-store-car to-store-btn" v-if="startTimer"></view> <view class="to-store-car to-store-btn" v-if="startTimer"></view>
</view> </view>
@ -303,15 +225,8 @@
<!-- 规格-模态层弹窗 --> <!-- 规格-模态层弹窗 -->
<view class="spec"> <view class="spec">
<!-- 促销弹窗 --> <!-- 促销弹窗 -->
<u-popup <u-popup v-model="promotionShow" :height="setup.height" :mode="setup.mode" :border-radius="setup.radius"
v-model="promotionShow" @close="promotionShow = false" :mask-close-able="setup.close" closeable>
:height="setup.height"
:mode="setup.mode"
:border-radius="setup.radius"
@close="promotionShow = false"
:mask-close-able="setup.close"
closeable
>
<view class="header-title">优惠</view> <view class="header-title">优惠</view>
<view class="cuxiao"> <view class="cuxiao">
<scroll-view class="scroll_mask" :scroll-y="true"> <scroll-view class="scroll_mask" :scroll-y="true">
@ -328,31 +243,14 @@
</u-popup> </u-popup>
<!-- 配送地址弹窗 --> <!-- 配送地址弹窗 -->
<popupAddress <popupAddress @closeAddress="closePopupAddress" @deliveryData="deliveryFun" v-if="goodsDetail.id"
@closeAddress="closePopupAddress" :goodsId="goodsDetail.id" :addressFlag="addressFlag" />
@deliveryData="deliveryFun"
v-if="goodsDetail.id"
:goodsId="goodsDetail.id"
:addressFlag="addressFlag"
/>
<!-- 商品规格 商品详情以及默认参与活动的id--> <!-- 商品规格 商品详情以及默认参与活动的id-->
<popupGoods <popupGoods :addr="delivery" ref="popupGoods" @changed="changedGoods" @closeBuy="closePopupBuy"
:addr="delivery" @queryCart="cartCount()" :goodsDetail="goodsDetail" :goodsSpec="goodsSpec" :isGroup="isGroup" :id="productId"
ref="popupGoods" v-if="goodsDetail.id" :pointDetail="pointDetail" :wholesaleList="wholesaleList" @handleClickSku="selectSku"
@changed="changedGoods" :buyMask="buyMask" />
@closeBuy="closePopupBuy"
@queryCart="cartCount()"
:goodsDetail="goodsDetail"
:goodsSpec="goodsSpec"
:isGroup="isGroup"
:id="productId"
v-if="goodsDetail.id"
:pointDetail="pointDetail"
:wholesaleList="wholesaleList"
@handleClickSku="selectSku"
:buyMask="buyMask"
/>
</view> </view>
</view> </view>
</div> </div>
@ -402,7 +300,7 @@ export default {
popupGoods, popupGoods,
popupAddress, popupAddress,
}, },
data() { data () {
return { return {
setup, setup,
promotionShow: false, // promotionShow: false, //
@ -445,7 +343,7 @@ export default {
enableShare: false, enableShare: false,
selectedGoods: "", // selectedGoods: "", //
isGroup: false, // isGroup: false, //
isSeckill:false, // isSeckill: false, //
pointDetail: "", // pointDetail: "", //
assemble: "", //sku assemble: "", //sku
navbarOnlyBack: { navbarOnlyBack: {
@ -524,19 +422,19 @@ export default {
routerVal: "", routerVal: "",
IMLink: "", // IM IMLink: "", // IM
wholesaleList:[] wholesaleList: []
}; };
}, },
computed: { computed: {
// udesk IM // udesk IM
IM() { IM () {
return this.IMLink + this.storeDetail.merchantEuid; return this.IMLink + this.storeDetail.merchantEuid;
}, },
}, },
watch: { watch: {
isGroup(val) { isGroup (val) {
if (val) { if (val) {
let timer = setInterval(() => { let timer = setInterval(() => {
this.$refs.popupGoods.buyType = "PINTUAN"; this.$refs.popupGoods.buyType = "PINTUAN";
@ -547,7 +445,7 @@ export default {
} }
}, },
}, },
mounted() { mounted () {
const { windowHeight } = uni.getSystemInfoSync(); const { windowHeight } = uni.getSystemInfoSync();
let bottomHeight = 0; let bottomHeight = 0;
let topHeight = 0; let topHeight = 0;
@ -577,7 +475,7 @@ export default {
this.productRefHeight = windowHeight - bottomHeight + "px"; this.productRefHeight = windowHeight - bottomHeight + "px";
}, },
async onLoad(options) { async onLoad (options) {
this.routerVal = options; this.routerVal = options;
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
// //
@ -587,7 +485,7 @@ export default {
}); });
// #endif // #endif
}, },
async onShow() { async onShow () {
this.goodsDetail = {}; this.goodsDetail = {};
//ids //ids
if (this.routerVal.scene) { if (this.routerVal.scene) {
@ -601,22 +499,22 @@ export default {
this.init(this.routerVal.id, this.routerVal.goodsId, this.routerVal.distributionId); this.init(this.routerVal.id, this.routerVal.goodsId, this.routerVal.distributionId);
} }
}, },
methods: { methods: {
share() { share () {
return `/pages/product/goods?id=${this.routerVal.id}&goodsId=${this.routerVal.goodsId}`; return `/pages/product/goods?id=${this.routerVal.id}&goodsId=${this.routerVal.goodsId}`;
}, },
/** /**
* 导航栏列表栏 * 导航栏列表栏
*/ */
handleNavbarList(val) { handleNavbarList (val) {
modelNavigateTo({ url: val }); modelNavigateTo({ url: val });
}, },
/** /**
* 循环出当前促销是否为空 * 循环出当前促销是否为空
*/ */
emptyPromotion() { emptyPromotion () {
if ( if (
this.PromotionList == "" || this.PromotionList == "" ||
this.PromotionList == null || this.PromotionList == null ||
@ -625,13 +523,13 @@ export default {
return true; return true;
} }
}, },
selectSku(idObj) { selectSku (idObj) {
this.init(idObj.skuId, idObj.goodsId); this.init(idObj.skuId, idObj.goodsId);
}, },
/** /**
* 初始化信息 * 初始化信息
*/ */
async init(id, goodsId, distributionId = "") { async init (id, goodsId, distributionId = "") {
this.isGroup = false; // this.isGroup = false; //
this.productId = id; // skuId this.productId = id; // skuId
// //
@ -664,7 +562,7 @@ export default {
if (item.indexOf("PINTUAN") == 0) { if (item.indexOf("PINTUAN") == 0) {
this.isGroup = true; this.isGroup = true;
} }
// //
if (item.indexOf("SECKILL") == 0) { if (item.indexOf("SECKILL") == 0) {
this.isSeckill = true this.isSeckill = true
@ -693,90 +591,90 @@ export default {
// this.getIMDetailMethods(); // this.getIMDetailMethods();
}, },
async getIMDetailMethods() { async getIMDetailMethods () {
let res = await getIMDetail(); let res = await getIMDetail();
if (res.data.success) { if (res.data.success) {
this.IMLink = res.data.result; this.IMLink = res.data.result;
} }
}, },
linkMsgDetail() { linkMsgDetail () {
// lili // lili
uni.navigateTo({ uni.navigateTo({
url: `/pages/mine/im/index?userId=`+this.goodsDetail.storeId, url: `/pages/mine/im/index?userId=${this.goodsDetail.storeId}&goodsid=${this.routerVal.goodsId}&skuid=${this.routerVal.id}`
}); });
// udesk // udesk
// if (this.storeDetail.merchantEuid) { // if (this.storeDetail.merchantEuid) {
// uni.navigateTo({ // uni.navigateTo({
// url: `/pages/tabbar/home/web-view?src=${this.IM}`, // url: `/pages/tabbar/home/web-view?src=${this.IM}`,
// }); // });
// } // }
// //
// // #ifdef MP-WEIXIN // // #ifdef MP-WEIXIN
// const params = { // const params = {
// storeName: this.storeDetail.storeName, // storeName: this.storeDetail.storeName,
// goodsName: this.goodsDetail.goodsName, // goodsName: this.goodsDetail.goodsName,
// goodsId: this.goodsDetail.goodsId, // goodsId: this.goodsDetail.goodsId,
// goodsImg: this.goodsDetail.thumbnail, // goodsImg: this.goodsDetail.thumbnail,
// price: this.goodsDetail.promotionPrice || this.goodsDetail.price, // price: this.goodsDetail.promotionPrice || this.goodsDetail.price,
// // originalPrice: this.goodsDetail.original || this.goodsDetail.price, // // originalPrice: this.goodsDetail.original || this.goodsDetail.price,
// uuid: storage.getUuid(), // uuid: storage.getUuid(),
// token: storage.getAccessToken(), // token: storage.getAccessToken(),
// sign: this.storeDetail.yzfSign, // sign: this.storeDetail.yzfSign,
// mpSign: this.storeDetail.yzfMpSign, // mpSign: this.storeDetail.yzfMpSign,
// }; // };
// uni.navigateTo({ // uni.navigateTo({
// url: // url:
// "/pages/product/customerservice/index?params=" + // "/pages/product/customerservice/index?params=" +
// encodeURIComponent(JSON.stringify(params)), // encodeURIComponent(JSON.stringify(params)),
// }); // });
// // #endif // // #endif
// // #ifndef MP-WEIXIN // // #ifndef MP-WEIXIN
// const sign = this.storeDetail.yzfSign; // const sign = this.storeDetail.yzfSign;
// uni.navigateTo({ // uni.navigateTo({
// url: // url:
// "/pages/tabbar/home/web-view?src=https://yzf.qq.com/xv/web/static/chat/index.html?sign=" + // "/pages/tabbar/home/web-view?src=https://yzf.qq.com/xv/web/static/chat/index.html?sign=" +
// sign, // sign,
// }); // });
// // #endif // // #endif
}, },
/**选择商品 */ /**选择商品 */
changedGoods(val) { changedGoods (val) {
this.selectedGoods = val; this.selectedGoods = val;
}, },
/** 点击子级地址回调参数*/ /** 点击子级地址回调参数*/
deliveryFun(val) { deliveryFun (val) {
this.delivery = val; this.delivery = val;
}, },
/** /**
* 地址子级关闭回调 * 地址子级关闭回调
*/ */
closePopupAddress(val) { closePopupAddress (val) {
this.addressFlag = val; this.addressFlag = val;
// this.maskFlag = false; // this.maskFlag = false;
}, },
/** /**
* 商品规格子级关闭回调 * 商品规格子级关闭回调
*/ */
closePopupBuy(val) { closePopupBuy (val) {
this.buyMask = val; this.buyMask = val;
// this.maskFlag = false; // this.maskFlag = false;
}, },
/** 参与拼团 创建拼团 */ /** 参与拼团 创建拼团 */
toAssembleBuyNow(order) { toAssembleBuyNow (order) {
this.shutMask(4, "PINTUAN", order); this.shutMask(4, "PINTUAN", order);
}, },
/** /**
* 查看购物车 * 查看购物车
*/ */
reluchToCart() { reluchToCart () {
let obj = { let obj = {
from: "product", from: "product",
id: this.productId, id: this.productId,
@ -790,7 +688,7 @@ export default {
/** /**
* 查询购物车总数量 * 查询购物车总数量
*/ */
cartCount() { cartCount () {
if (storage.getHasLogin()) { if (storage.getHasLogin()) {
API_trade.getCartNum().then((res) => { API_trade.getCartNum().then((res) => {
this.nums = res.data.result; this.nums = res.data.result;
@ -801,7 +699,7 @@ export default {
/** /**
* 返回 * 返回
*/ */
back() { back () {
if (getCurrentPages().length == 1) { if (getCurrentPages().length == 1) {
uni.switchTab({ uni.switchTab({
url: "/pages/tabbar/home/index", url: "/pages/tabbar/home/index",
@ -814,7 +712,7 @@ export default {
/** /**
* 获取店铺信息 * 获取店铺信息
*/ */
getStoreBaseInfoFun(id) { getStoreBaseInfoFun (id) {
API_store.getStoreBaseInfo(id).then((res) => { API_store.getStoreBaseInfo(id).then((res) => {
if (res.data.success) { if (res.data.success) {
this.storeDetail = res.data.result; this.storeDetail = res.data.result;
@ -825,7 +723,7 @@ export default {
/** /**
* 删除收藏店铺 * 删除收藏店铺
*/ */
deleteGoodsCollectionFun(id) { deleteGoodsCollectionFun (id) {
API_Members.deleteGoodsCollection(id).then((res) => { API_Members.deleteGoodsCollection(id).then((res) => {
if (res.statusCode == 200) { if (res.statusCode == 200) {
uni.showToast({ uni.showToast({
@ -840,7 +738,7 @@ export default {
/** /**
* 获取商品是否已被收藏 * 获取商品是否已被收藏
*/ */
getGoodsCollectionFun(goodsId) { getGoodsCollectionFun (goodsId) {
if (storage.getHasLogin()) { if (storage.getHasLogin()) {
API_Members.getGoodsIsCollect("GOODS", goodsId).then((res) => { API_Members.getGoodsIsCollect("GOODS", goodsId).then((res) => {
this.favorite = res.data.result; this.favorite = res.data.result;
@ -851,7 +749,7 @@ export default {
/** /**
* 获取店铺推荐商品列表 * 获取店铺推荐商品列表
*/ */
getStoreRecommend() { getStoreRecommend () {
getGoodsList({ getGoodsList({
pageNumber: 1, pageNumber: 1,
pageSize: 6, pageSize: 6,
@ -866,7 +764,7 @@ export default {
* 获取相似商品列表 * 获取相似商品列表
* *
*/ */
getOtherLikeGoods() { getOtherLikeGoods () {
getGoodsList({ getGoodsList({
pageNumber: 1, pageNumber: 1,
pageSize: 10, pageSize: 10,
@ -880,7 +778,7 @@ export default {
/** /**
* 领取优惠券 * 领取优惠券
*/ */
receiveCouponsFun(id) { receiveCouponsFun (id) {
API_Members.receiveCoupons(id).then((res) => { API_Members.receiveCoupons(id).then((res) => {
uni.showToast({ uni.showToast({
title: res.data.message, title: res.data.message,
@ -892,7 +790,7 @@ export default {
/** /**
* 跳转到店铺页面 * 跳转到店铺页面
*/ */
navigateToStore(store_id) { navigateToStore (store_id) {
uni.navigateTo({ uni.navigateTo({
url: `/pages/product/shopPage?id=` + store_id, url: `/pages/product/shopPage?id=` + store_id,
}); });
@ -901,14 +799,14 @@ export default {
/** /**
* 获取优惠券按钮 * 获取优惠券按钮
*/ */
getCoupon(item) { getCoupon (item) {
this.receiveCouponsFun(item.id); this.receiveCouponsFun(item.id);
}, },
/** /**
* 规格弹窗开关 * 规格弹窗开关
*/ */
shutMask(flag, buyFlag, type) { shutMask (flag, buyFlag, type) {
this.promotionShow = false; this.promotionShow = false;
this.buyMask = false; this.buyMask = false;
this.addressFlag = false; this.addressFlag = false;
@ -943,7 +841,7 @@ export default {
/** /**
* 收藏 * 收藏
*/ */
clickFavorite(id) { clickFavorite (id) {
if (this.favorite) { if (this.favorite) {
// //
this.deleteGoodsCollectionFun(id); this.deleteGoodsCollectionFun(id);
@ -963,7 +861,7 @@ export default {
/** /**
* 顶部header显示或隐藏 * 顶部header显示或隐藏
*/ */
pageScroll(e) { pageScroll (e) {
if (this.scrollFlag) { if (this.scrollFlag) {
this.calcSize(); this.calcSize();
} }
@ -991,7 +889,7 @@ export default {
/** /**
* 计算每个要跳转到的模块高度信息 * 计算每个要跳转到的模块高度信息
*/ */
calcSize() { calcSize () {
let h = 0; let h = 0;
let that = this; let that = this;
let arr = [ let arr = [
@ -1036,7 +934,7 @@ export default {
/** /**
* 点击顶部跳转到对应位置 * 点击顶部跳转到对应位置
*/ */
headerTab(id) { headerTab (id) {
if (this.scrollFlag) { if (this.scrollFlag) {
this.calcSize(); this.calcSize();
} }
@ -1050,7 +948,7 @@ export default {
/** /**
* 点击分享 * 点击分享
*/ */
async shareChange() { async shareChange () {
this.enableShare = true; this.enableShare = true;
}, },
}, },