+
+
-
+
{{ val.goodsSku.goodsName }}
x{{ val.num }}
@@ -147,7 +122,7 @@
¥
{{
- $options.filters.goodsFormatPrice(val.purchasePrice)[0]
+ $options.filters.goodsFormatPrice(val.purchasePrice)[0]
}}
.{{ $options.filters.goodsFormatPrice(val.purchasePrice)[1] }}
@@ -155,111 +130,65 @@
发票信息
-
- {{ receiptList.receiptTitle }} -
- {{ receiptList.receiptContent }}
+
+ {{ receiptList.receiptTitle }} -
+ {{ receiptList.receiptContent }}
不开发票
- 配送
+ 配送
-
+
{{
- shippingMethod.find((e) => {
- return e.value == shippingText;
- }).label
+ shippingMethod.find((e) => {
+ return e.value == shippingText;
+ }).label
}}
- 备注信息
+ 备注信息
-
+
-
-
+
+
商品合计
- ¥{{ orderMessage.priceDetailDTO.goodsPrice | unitPrice }}
+ ¥{{ orderMessage.priceDetailDTO.goodsPrice | unitPrice }}
-
- 运费
-
- 包邮
- ¥{{
+
+ 运费
+
+ 包邮
+ ¥{{
orderMessage.priceDetailDTO.freightPrice | unitPrice
- }}
+ }}
优惠券
-
- -¥{{ orderMessage.priceDetailDTO.couponPrice | unitPrice }}
+
+ -¥{{ orderMessage.priceDetailDTO.couponPrice | unitPrice }}
@@ -270,15 +199,10 @@
优惠金额
-
+
- -¥{{ orderMessage.priceDetailDTO.couponPrice | unitPrice }}
+ -¥{{ orderMessage.priceDetailDTO.couponPrice | unitPrice }}
+
0.00
@@ -286,11 +210,9 @@
活动优惠
- -¥{{
+ -¥{{
orderMessage.priceDetailDTO.discountPrice | unitPrice
- }}
+ }}
0.00
@@ -299,12 +221,7 @@
-
+
@@ -315,18 +232,14 @@
¥
{{
- $options.filters.goodsFormatPrice(orderMessage.priceDetailDTO.flowPrice)[0]
+ $options.filters.goodsFormatPrice(orderMessage.priceDetailDTO.flowPrice)[0]
}}
- .{{ $options.filters.goodsFormatPrice(orderMessage.priceDetailDTO.flowPrice)[1] }}
+ .{{ $options.filters.goodsFormatPrice(orderMessage.priceDetailDTO.flowPrice)[1] }}
- {{
+ {{
orderMessage.priceDetailDTO.payPoint | unitPrice
- }}积分
+ }}积分
@@ -361,11 +274,16 @@ export default {
invoiceFlag: false, //开票开关
shippingText: "LOGISTICS",
shippingFlag: false,
- shippingMethod: [
+ shippingMethod: [],
+ shippingWay: [
{
value: "LOGISTICS",
label: "物流",
},
+ {
+ value: "SELF_PICK_UP",
+ label: "自提",
+ },
],
isAssemble: false, //是否拼团
couponNums: "", //结算页面优惠券数量
@@ -376,6 +294,7 @@ export default {
couponList: "",
// 已选地址
address: "",
+ shopAddress: "",
// 发票信息
receiptList: "",
// 店铺信息
@@ -438,11 +357,12 @@ export default {
}
},
- onShow() {
+ async onShow() {
uni.showLoading({
mask: true,
});
- this.getOrderList();
+ await this.getOrderList();
+ await this.getDistribution();
uni.hideLoading();
if (this.routerVal.way == "PINTUAN") {
this.isAssemble = true;
@@ -452,7 +372,7 @@ export default {
this.pintuanWay();
}
},
- mounted() {},
+ mounted() { },
methods: {
//发票回调 选择发票之后刷新购物车
@@ -481,13 +401,18 @@ export default {
// 点击跳转地址
clickToAddress() {
this.navigateTo(
- `/pages/mine/address/address?from=cart&way=${
- this.routerVal.way
+ `/pages/mine/address/address?from=cart&way=${this.routerVal.way
}&parentOrder=${encodeURIComponent(
JSON.stringify(this.routerVal.parentOrder)
)}`
);
},
+ clickToStoreAddress() {
+ this.navigateTo(
+ `/pages/mine/address/storeAddress?from=cart&way=${this.routerVal.way
+ }&storeId=${this.remarkVal[0].storeId}`
+ );
+ },
// 判断团长以及团员信息
pintuanWay() {
@@ -561,14 +486,26 @@ export default {
createTradeFun() {
// 防抖
this.$u.throttle(() => {
- if (!this.address.id) {
- uni.showToast({
- title: "请选择地址",
- duration: 2000,
- icon: "none",
- });
- return false;
+ if (this.shippingText === 'SELF_PICK_UP') {
+ if (!this.storeAddress.id) {
+ uni.showToast({
+ title: "请选择提货点",
+ duration: 2000,
+ icon: "none",
+ });
+ return false;
+ }
+ } else if (this.shippingText === 'LOGISTICS') {
+ if (!this.address.id) {
+ uni.showToast({
+ title: "请选择地址",
+ duration: 2000,
+ icon: "none",
+ });
+ return false;
+ }
}
+
// 创建订单
let client;
// #ifdef H5
@@ -653,9 +590,40 @@ export default {
}
});
},
+ // 获取配送列表
+ async getDistribution() {
+ let shopRes = await API_Trade.shippingMethodList({ way: this.routerVal.way });
+ let shopList;
+ if (shopRes.data.success) {
+ shopList = shopRes.data.result;
+ let way = [];
+ console.log(shopList)
+ this.shippingWay.forEach((item) => {
+ shopList.forEach((child) => {
+ if (item.value == child) {
+ way.push(item);
+ }
+ });
+ });
+ this.shippingMethod = way;
+ }
+ },
+
+ // 选择配送
+ async confirmDistribution(val) {
+ let res = await API_Trade.setShipMethod({
+ shippingMethod: val[0].value,
+ way: this.routerVal.way,
+ });
+
+ this.shippingText = val[0].value;
+ if (res.data.success) {
+ this.getOrderList();
+ }
+ },
// 获取结算参数
- getOrderList() {
+ async getOrderList() {
this.notSupportFreight = [];
// 获取结算参数
API_Trade.getCheckoutParams(this.routerVal.way).then((res) => {
@@ -694,7 +662,9 @@ export default {
res.data.result.memberAddress.consigneeAddressPath =
res.data.result.memberAddress.consigneeAddressPath.split(",");
}
-
+ if (res.data.result.storeAddress) {
+ this.storeAddress = res.data.result.storeAddress
+ }
if (
res.data.result.notSupportFreight &&
res.data.result.notSupportFreight.length != 0
@@ -725,22 +695,26 @@ page {
.main-color {
font-weight: bold;
}
+
.uinput {
/deep/ input {
text-align: right;
}
}
+
.promotionNotice {
font-size: 24rpx;
margin: 20rpx 0;
color: $aider-light-color;
}
+
.nums {
flex: 2;
color: $light-color;
text-align: center;
}
+
.wait {
font-size: 22rpx;
font-family: PingFang SC, PingFang SC-Regular;
@@ -756,6 +730,7 @@ page {
width: 143rpx;
border-bottom: 2px dotted #999;
}
+
.tabbar-left {
margin-left: 32rpx;
}
@@ -808,6 +783,7 @@ page {
align-items: center;
justify-content: center;
}
+
.tr {
text-align: right;
}
@@ -830,6 +806,7 @@ page {
.box2 {
margin-top: 20rpx;
}
+
.notSupportFreight {
position: fixed;
@@ -845,10 +822,11 @@ page {
width: 100%;
transition: 0.35s;
- > .tips {
+ >.tips {
margin: 0 32rpx;
}
}
+
/deep/ .u-notice-bar-wrap {
width: 100% !important;
}
@@ -926,7 +904,8 @@ page {
color: $main-color;
font-size: 26rpx;
font-weight: bold;
- > span {
+
+ >span {
font-size: 36rpx;
}
}
@@ -936,7 +915,8 @@ page {
color: $main-color;
font-size: 28rpx;
font-weight: bold;
- > .goods-price {
+
+ >.goods-price {
font-size: 38rpx;
padding: 0 2rpx;
}
@@ -977,6 +957,7 @@ page {
text-align: left;
overflow: hidden;
}
+
.default {
background: $main-color;
font-size: 24rpx;
@@ -985,6 +966,7 @@ page {
color: #fff;
margin-right: 20rpx;
}
+
.address-box {
border-radius: 40rpx;
border-top-left-radius: 0 !important;
@@ -999,9 +981,11 @@ page {
font-weight: normal;
letter-spacing: 1rpx;
}
+
.user-box {
padding: 32rpx;
}
+
.user-address-detail {
color: #333;
font-size: 38rpx;
@@ -1009,13 +993,16 @@ page {
margin: 20rpx 0;
letter-spacing: 1rpx;
}
+
.mobile {
margin-left: 20rpx;
}
+
.price {
font-size: 50rpx !important;
margin: 0 2rpx;
}
+
.goods-detail {
display: flex;
flex-direction: column;
@@ -1023,12 +1010,14 @@ page {
justify-content: center;
flex: 8;
margin-left: 20rpx !important;
- > p {
+
+ >p {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
+
.goods-item {
margin: 20rpx 0;
}
diff --git a/pages/order/orderDetail.vue b/pages/order/orderDetail.vue
index 4014a7e..84c7ece 100644
--- a/pages/order/orderDetail.vue
+++ b/pages/order/orderDetail.vue
@@ -12,25 +12,25 @@
- {{logiList.traces[logiList.traces.length-1].AcceptStation}}
+ {{ logiList.traces[logiList.traces.length - 1].AcceptStation }}
- {{logiList.traces[logiList.traces.length-1].AcceptTime}}
+ {{ logiList.traces[logiList.traces.length - 1].AcceptTime }}
-
- 券码: {{order.verificationCode}}
+
+ 券码: {{ order.verificationCode }}
- {{'暂无物流信息'}}
+ {{ '暂无物流信息' }}
-
+
@@ -42,6 +42,21 @@
+
+
+
+
+
+
+ 自提点地址:{{ order.storeAddressPath }}
+
+
+ 联系方式:{{ order.storeAddressMobile }}
+
+
+
+
+
@@ -49,7 +64,8 @@
{{ order.storeName }}
- {{ orderStatusList[order.orderStatus].title }}
+ {{ orderStatusList[order.orderStatus].title
+ }}
@@ -70,7 +86,8 @@
x{{ sku.num }}
-
+
@@ -105,15 +122,18 @@
+ v-if="orderDetail.allowOperationVO && orderDetail.allowOperationVO.cancel == true || order.orderStatus == 'DELIVERED' || order.orderStatus != 'UNPAID' && order.orderPromotionType == 'PINTUAN'">
服务
- 取消订单
+ 取消订单
查看物流
- 查看拼团信息
+ 查看拼团信息
@@ -129,18 +149,18 @@
下单时间:
{{
- order.createTime
+ order.createTime
}}
支付状态:
{{
- order.payStatus == "UNPAID"
- ? "未付款"
- : order.payStatus == "PAID"
- ? "已付款"
- : ""
+ order.payStatus == "UNPAID"
+ ? "未付款"
+ : order.payStatus == "PAID"
+ ? "已付款"
+ : ""
}}
@@ -175,13 +195,16 @@
- 立即付款
+ 立即付款
- 确认收货
+ 确认收货
- 评价商品
+ 评价商品
@@ -193,7 +216,8 @@
- {{ item.reason }}
+ {{ item.reason }}
@@ -204,10 +228,12 @@
-
+
-
+
@@ -255,6 +281,10 @@ export default {
title: "已完成",
value: "订单已完成,祝您生活愉快",
},
+ STAY_PICKED_UP: {
+ title: "待自提",
+ value: "商品正在等待提取",
+ },
TAKE: {
title: "待核验",
},
@@ -272,7 +302,6 @@ export default {
},
onLoad(options) {
this.loadData(options.sn);
- this.loadLogistics(options.sn);
this.sn = options.sn;
},
methods: {
@@ -304,7 +333,7 @@ export default {
this.orderGoodsList[0].goodsId,
});
},
- loadData(sn) {
+ async loadData(sn) {
uni.showLoading({
title: "加载中",
});
@@ -313,9 +342,12 @@ export default {
this.order = order.order;
this.orderGoodsList = order.orderItems;
this.orderDetail = res.data.result;
-
+ if (this.order.deliveryMethod === 'LOGISTICS') {
+ this.loadLogistics()
+ }
uni.hideLoading();
});
+
},
onReceipt(val) {
uni.navigateTo({
@@ -383,8 +415,8 @@ export default {
toPay(val) {
val.sn
? uni.navigateTo({
- url: "/pages/cart/payment/payOrder?order_sn=" + val.sn,
- })
+ url: "/pages/cart/payment/payOrder?order_sn=" + val.sn,
+ })
: false;
}, //删除订单
deleteOrder(index) {
@@ -491,9 +523,11 @@ export default {
+
+
diff --git a/pages/mine/im/list.vue b/pages/mine/im/list.vue
new file mode 100644
index 0000000..c05104d
--- /dev/null
+++ b/pages/mine/im/list.vue
@@ -0,0 +1,229 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 清除未读
+
+
+
+
+
+ 系统消息
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ item.name }}
+
+
+
+ {{ item.lastTalkMessage }}
+
+
+
+
+ {{ beautifyTime(item.lastTalkTime) }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/order/myOrder.vue b/pages/order/myOrder.vue
index f4cdfc8..452797b 100644
--- a/pages/order/myOrder.vue
+++ b/pages/order/myOrder.vue
@@ -814,3 +814,4 @@ page,
height: 60rpx;
}
+
diff --git a/pages/product/goods.vue b/pages/product/goods.vue
index 3447387..14f7e66 100644
--- a/pages/product/goods.vue
+++ b/pages/product/goods.vue
@@ -704,7 +704,7 @@ export default {
// lili 基础客服
uni.navigateTo({
- url: `/pages/tabbar/home/web-view?IM=${this.storeDetail.storeId}`,
+ url: `/pages/mine/im/index?userId=`+this.goodsDetail.storeId,
});
// udesk 代码
diff --git a/pages/product/shopPage.vue b/pages/product/shopPage.vue
index df5898b..01188a8 100644
--- a/pages/product/shopPage.vue
+++ b/pages/product/shopPage.vue
@@ -314,17 +314,21 @@ export default {
};
uni.navigateTo({
url:
- "/pages/product/customerservice/index?params=" +
- encodeURIComponent(JSON.stringify(params)),
- });
- // #endif
- // #ifndef MP-WEIXIN
- const sign = this.storeInfo.yzfSign;
- uni.navigateTo({
- url:
- "/pages/tabbar/home/web-view?src=https://yzf.qq.com/xv/web/static/chat/index.html?sign=" +
- sign,
+ "/pages/mine/im/index"
});
+ // uni.navigateTo({
+ // url:
+ // "/pages/product/customerservice/index?params=" +
+ // encodeURIComponent(JSON.stringify(params)),
+ // });
+ // // #endif
+ // // #ifndef MP-WEIXIN
+ // const sign = this.storeInfo.yzfSign;
+ // uni.navigateTo({
+ // url:
+ // "/pages/tabbar/home/web-view?src=https://yzf.qq.com/xv/web/static/chat/index.html?sign=" +
+ // sign,
+ // });
// #endif
},
diff --git a/pages/tabbar/user/my.vue b/pages/tabbar/user/my.vue
index 4faa82a..df5bf82 100644
--- a/pages/tabbar/user/my.vue
+++ b/pages/tabbar/user/my.vue
@@ -21,7 +21,7 @@
预存款
- {{ walletNum | unitPrice}}
+ {{ walletNum | unitPrice }}
@@ -36,7 +36,6 @@
-
@@ -61,12 +60,12 @@
售后
-
-
-
-
- 我的订单
-
+
+
+
+
+ 我的订单
+
@@ -94,7 +93,7 @@ export default {
walletNum: "",
};
},
- onLoad() {},
+ onLoad() { },
onShow() {
this.userInfo = this.$options.filters.isLogin();
if (this.$options.filters.isLogin("auth")) {
@@ -116,7 +115,7 @@ export default {
},
// #endif
- mounted() {},
+ mounted() { },
methods: {
/**
* 统一跳转接口,拦截未登录路由
@@ -154,6 +153,7 @@ html,
body {
overflow: auto;
}
+
.money {
overflow: hidden;
@@ -175,12 +175,14 @@ body {
color: #ffffff;
display: flex;
justify-content: space-between;
+
.head-1 {
text-align: center;
width: 152rpx;
position: relative;
display: flex;
align-items: center;
+
image {
width: 152rpx;
height: 144rpx;
@@ -188,6 +190,7 @@ body {
margin-bottom: 30rpx;
border: 3px solid #fff;
}
+
.edti-head {
position: absolute;
width: 40rpx;
@@ -196,23 +199,27 @@ body {
background-color: rgba(255, 255, 255, 0.3);
top: 100rpx;
right: 0;
+
image {
width: 100%;
height: 100%;
}
}
}
+
.head-2 {
flex: 1;
margin-left: 30rpx;
margin-top: 100rpx;
line-height: 1;
}
+
/deep/ .u-icon,
.u-icon {
margin-top: 106rpx;
}
}
+
.pointBox {
width: 94%;
margin: 0 3%;
@@ -220,6 +227,7 @@ body {
border-radius: 20rpx;
box-shadow: 0 4rpx 24rpx 0 rgba($color: #f6f6f6, $alpha: 1);
}
+
.point {
text-align: center;
height: 160rpx;
@@ -227,12 +235,14 @@ body {
font-size: $font-sm;
// #ifdef MP-WEIXIN
padding: 24rpx;
+
// #endif
.u-col {
view {
color: $u-main-color;
font-size: 28rpx;
}
+
view:last-child {
margin-top: 8rpx;
color: $main-color;
@@ -240,6 +250,7 @@ body {
}
}
}
+
.order {
height: 140rpx;
text-align: center;
@@ -249,10 +260,12 @@ body {
align-items: center;
padding: 0 3%;
color: #999;
+
.order-item {
position: relative;
line-height: 2em;
width: 96rpx;
+
:first-child {
font-size: 48rpx;
margin-bottom: 10rpx;
@@ -264,6 +277,7 @@ body {
.box {
transform: translateY(-30rpx);
}
+
.user-name {
font-size: 34rpx;
}
diff --git a/pages/tabbar/user/utils/tool.vue b/pages/tabbar/user/utils/tool.vue
index 78ebf35..9fe6b10 100644
--- a/pages/tabbar/user/utils/tool.vue
+++ b/pages/tabbar/user/utils/tool.vue
@@ -126,7 +126,7 @@ export default {
linkMsgDetail(){
uni.navigateTo({
- url: `/pages/tabbar/home/web-view?IM=0`,
+ url: `/pages/mine/im/list`,
});
},
diff --git a/utils/filters.js b/utils/filters.js
index 0fbb778..d1b7fb4 100644
--- a/utils/filters.js
+++ b/utils/filters.js
@@ -85,6 +85,62 @@ export function unixToDate(unix, format) {
return _format;
}
+/**
+ * 人性化显示时间
+ *
+ * @param {Object} datetime
+ */
+ export function beautifyTime(datetime = "") {
+ if (datetime == null || datetime == undefined || !datetime) {
+ return "";
+ }
+
+ datetime = datetime.replace(/-/g, "/");
+
+ let time = new Date();
+ let outTime = new Date(datetime);
+ if (/^[1-9]\d*$/.test(datetime)) {
+ outTime = new Date(parseInt(datetime) * 1000);
+ }
+
+ if (time.getTime() < outTime.getTime()) {
+ return parseTime(outTime, "{y}/{m}/{d}");
+ }
+
+ if (time.getFullYear() != outTime.getFullYear()) {
+ return parseTime(outTime, "{y}/{m}/{d}");
+ }
+
+ if (time.getMonth() != outTime.getMonth()) {
+ return parseTime(outTime, "{m}/{d}");
+ }
+
+ if (time.getDate() != outTime.getDate()) {
+ let day = outTime.getDate() - time.getDate();
+ if (day == -1) {
+ return parseTime(outTime, "昨天 {h}:{i}");
+ }
+
+ if (day == -2) {
+ return parseTime(outTime, "前天 {h}:{i}");
+ }
+
+ return parseTime(outTime, "{m}-{d}");
+ }
+
+ if (time.getHours() != outTime.getHours()) {
+ return parseTime(outTime, "{h}:{i}");
+ }
+
+ let minutes = outTime.getMinutes() - time.getMinutes();
+ if (minutes == 0) {
+ return "刚刚";
+ }
+
+ minutes = Math.abs(minutes);
+ return `${minutes}分钟前`;
+}
+
/**
* 13888888888 -> 138****8888
* @param mobile
@@ -98,6 +154,111 @@ export function secrecyMobile(mobile) {
return mobile.replace(/(\d{3})(\d{4})(\d{4})/, "$1****$3");
}
+/**
+ * 人性化时间显示
+ *
+ * @param {Object} datetime
+ */
+ export function formatTime(datetime) {
+ if (datetime == null) return "";
+
+ datetime = datetime.replace(/-/g, "/");
+
+ let time = new Date();
+ let outTime = new Date(datetime);
+ if (/^[1-9]\d*$/.test(datetime)) {
+ outTime = new Date(parseInt(datetime) * 1000);
+ }
+
+ if (
+ time.getTime() < outTime.getTime() ||
+ time.getFullYear() != outTime.getFullYear()
+ ) {
+ return parseTime(outTime, "{y}-{m}-{d} {h}:{i}");
+ }
+
+ if (time.getMonth() != outTime.getMonth()) {
+ return parseTime(outTime, "{m}-{d} {h}:{i}");
+ }
+
+ if (time.getDate() != outTime.getDate()) {
+ let day = outTime.getDate() - time.getDate();
+ if (day == -1) {
+ return parseTime(outTime, "昨天 {h}:{i}");
+ }
+
+ if (day == -2) {
+ return parseTime(outTime, "前天 {h}:{i}");
+ }
+
+ return parseTime(outTime, "{m}-{d} {h}:{i}");
+ }
+
+ if (time.getHours() != outTime.getHours()) {
+ return parseTime(outTime, "{h}:{i}");
+ }
+
+ let minutes = outTime.getMinutes() - time.getMinutes();
+ if (minutes == 0) {
+ return "刚刚";
+ }
+
+ minutes = Math.abs(minutes);
+ return `${minutes}分钟前`;
+}
+
+/**
+ * 时间格式化方法
+ *
+ * @param {(Object|string|number)} time
+ * @param {String} cFormat
+ * @returns {String | null}
+ */
+ export function parseTime(time, cFormat) {
+ if (arguments.length === 0) {
+ return null;
+ }
+
+ let date;
+ const format = cFormat || "{y}-{m}-{d} {h}:{i}:{s}";
+
+ if (typeof time === "object") {
+ date = time;
+ } else {
+ if (typeof time === "string" && /^[0-9]+$/.test(time)) {
+ time = parseInt(time);
+ }
+ if (typeof time === "number" && time.toString().length === 10) {
+ time = time * 1000;
+ console.log("时间判断为number");
+ }
+
+ date = new Date(time.replace(/-/g, "/"));
+ }
+
+ const formatObj = {
+ y: date.getFullYear(),
+ m: date.getMonth() + 1,
+ d: date.getDate(),
+ h: date.getHours(),
+ i: date.getMinutes(),
+ s: date.getSeconds(),
+ a: date.getDay(),
+ };
+
+ const time_str = format.replace(/{([ymdhisa])+}/g, (result, key) => {
+ const value = formatObj[key];
+ // Note: getDay() returns 0 on Sunday
+ if (key === "a") {
+ return ["日", "一", "二", "三", "四", "五", "六"][value];
+ }
+
+ return value.toString().padStart(2, "0");
+ });
+
+ return time_str;
+}
+
/**
* 清除逗号
*
diff --git a/utils/socket_service.js b/utils/socket_service.js
new file mode 100644
index 0000000..4d010ee
--- /dev/null
+++ b/utils/socket_service.js
@@ -0,0 +1,86 @@
+import store from '@/store/index'
+import config from '@/config/config.js'
+import storage from './storage';
+export default class SocketService {
+ /**
+ * 单例
+ */
+ static instance = null;
+ static get Instance() {
+ if (!this.instance) {
+ this.instance = new SocketService();
+ }
+ return this.instance;
+ }
+
+ // 和服务端连接的socket对象
+ ws = null;
+
+ // 存储回调函数
+ callBackMapping = {};
+
+ // 标识是否连接成功
+ connected = false;
+
+ // 记录重试的次数
+ sendRetryCount = 0;
+
+ // 重新连接尝试的次数
+ connectRetryCount = 0;
+
+ // 定义连接服务器的方法
+ connect() {
+ // 连接服务器
+ if (!window.WebSocket) {
+ return console.log("您的浏览器不支持WebSocket");
+ }
+ this.ws = new WebSocket(config.BASE_WS_URL+'/'+storage.getAccessToken());
+ // 连接成功的事件
+ this.ws.onopen = () => {
+ console.log("连接服务端成功");
+ this.connected = true;
+ // 重置重新连接的次数
+ this.connectRetryCount = 0;
+ };
+ // 1.连接服务端失败
+ // 2.当连接成功之后, 服务器关闭的情况(连接失败重连)
+ this.ws.onclose = () => {
+ console.log("连接服务端失败");
+ this.connected = false;
+ this.connectRetryCount++;
+ setTimeout(() => {
+ this.connect();
+ }, 500 * this.connectRetryCount);
+ };
+ // 得到服务端发送过来的数据
+ this.ws.onmessage = (msg) => {
+ // console.log(msg.data)
+ this.registerCallBack(msg.data);
+ };
+ }
+ // 回调函数的注册
+ registerCallBack(callBack) {
+ // console.log("回调函数的注册", callBack);
+ this.callBackMapping = callBack;
+ }
+
+ // 取消某一个回调函数
+ unRegisterCallBack(callBack) {
+ console.log("取消某一个回调函数", callBack);
+ this.callBackMapping = null;
+ }
+
+ // 发送数据的方法
+ send(data) {
+ // 判断此时此刻有没有连接成功
+ if (this.connected) {
+ this.sendRetryCount = 0;
+ this.ws.send(data);
+ } else {
+ this.sendRetryCount++;
+ setTimeout(() => {
+ this.send(data);
+ }, this.sendRetryCount * 500);
+ }
+ }
+}
diff --git a/utils/storage.js b/utils/storage.js
index f7befdd..64ac7b8 100644
--- a/utils/storage.js
+++ b/utils/storage.js
@@ -52,6 +52,12 @@ export default {
getUserInfo() {
return uni.getStorageSync(USER_INFO);
},
+ setTalkToUser(val){
+ uni.setStorageSync("TALK_TO_USER", val);
+ },
+ getTalkToUser(){
+ return uni.getStorageSync("TALK_TO_USER");
+ },
// 写入uuid
setUuid(val) {
uni.setStorageSync(UUID, val);
From 04bf7078364a8b1340d5aee188ed0c2ce78712d0 Mon Sep 17 00:00:00 2001
From: chc <1501738723@qq.com>
Date: Tue, 27 Dec 2022 14:48:41 +0800
Subject: [PATCH 04/10] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=B6=88=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/mine/im/index.vue | 2 ++
1 file changed, 2 insertions(+)
diff --git a/pages/mine/im/index.vue b/pages/mine/im/index.vue
index 85e83aa..2e053d5 100644
--- a/pages/mine/im/index.vue
+++ b/pages/mine/im/index.vue
@@ -146,6 +146,7 @@ export default {
this.getTalkMessage()
} else {
this.getTalk(options.userId)
+
}
this.ws.connect();
@@ -365,6 +366,7 @@ export default {
if (res.data.success) {
this.toUser = res.data.result
this.params.talkId = res.data.result.id
+ this.getTalkMessage()
}
})
},
From 18251dde89585f0ffede806162483efc0cabe99a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=A8=8B?= <994041296@163.com>
Date: Tue, 27 Dec 2022 14:49:23 +0800
Subject: [PATCH 05/10] =?UTF-8?q?=E8=81=8A=E5=A4=A9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
api/im.js | 7 +
pages/mine/im/index.vue | 874 ++++++++++++++++++++--------------------
pages/product/goods.vue | 396 +++++++-----------
3 files changed, 590 insertions(+), 687 deletions(-)
diff --git a/api/im.js b/api/im.js
index 2301796..45be304 100644
--- a/api/im.js
+++ b/api/im.js
@@ -64,4 +64,11 @@ export function getTalk(talkId) {
params
});
}
+// 从商品页点击 客服 跳转 获取聊天记录
+export function jumpObtain(skuId, goodsId) {
+ return http.request({
+ url: `${api.im}/goods/goods/sku/${goodsId}/${skuId}`,
+ method: Method.GET,
+ });
+}
diff --git a/pages/mine/im/index.vue b/pages/mine/im/index.vue
index 85e83aa..f267b7c 100644
--- a/pages/mine/im/index.vue
+++ b/pages/mine/im/index.vue
@@ -1,102 +1,100 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
- {{ user.nickName }}
-
- {{ item.text }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
- {{ toUser.name }}
-
- {{ item.text }}
-
-
+
+
+
+ {{ toUser.name }}
+
+ {{ item.text }}
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 发送
-
-
-
-
-
-
-
- 问题反馈
-
-
-
- 人工客服
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 发送
+
+
+
+
+
+
+
+ 问题反馈
+
+
+
+ 人工客服
+
+
+
+
diff --git a/pages/product/goods.vue b/pages/product/goods.vue
index 14f7e66..c084919 100644
--- a/pages/product/goods.vue
+++ b/pages/product/goods.vue
@@ -6,55 +6,27 @@
-
-
+
+
-
+