6
0
Fork 0

修改返利状态,视频样式

hui.zhou
H 2022-09-08 10:13:22 +08:00
parent f18fe8a08f
commit 15ba1ce3c6
3 changed files with 476 additions and 459 deletions

View File

@ -1,17 +1,19 @@
<template>
<view class="px-30rpx pt-20rpx">
<view class="sticky top-0 z-1500 bg-hex-F5F5F5 rounded-full grid grid-cols-3 text-28rpx text-hex-333 leading-40rpx py-10rpx">
<view
class="sticky top-0 z-1500 bg-hex-F5F5F5 rounded-full grid grid-cols-3 text-28rpx text-hex-333 leading-40rpx py-10rpx">
<view class="text-center">时间</view>
<view class="text-center">返利</view>
<view class="text-center">状态</view>
</view>
<mescroll-body :height="height" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption"
:up="upOption">
<mescroll-body :height="height" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
:down="downOption" :up="upOption">
<block v-for="(item,index) in dataList" :key="index">
<view class="grid grid-cols-3 text-28rpx text-h666 py-18rpx mt-16rpx ">
<view class="grid grid-cols-3 text-28rpx text-h666 py-18rpx mt-16rpx ">
<view class="text-center line-1 ">{{item.created_at*1000 | date('yyyy-mm-dd')}}</view>
<view class="text-center price-text">{{item.money}}</view>
<view class="text-center ">{{item.status |StatusText}}</view>
<!-- <view class="text-center ">{{item.status |StatusText}}</view> -->
<view class="text-center ">{{item.status_text}}</view>
</view>
<u-line></u-line>
</block>
@ -37,8 +39,8 @@
dataList: [], //
};
},
filters:{
StatusText(value){
filters: {
StatusText(value) {
const status = [{
value: 0,
label: '待付款'
@ -56,7 +58,7 @@
return obj?.label ?? value
}
},
computed:{
computed: {
height() {
const {
windowHeight,
@ -81,7 +83,7 @@
}).then(res => {
this.mescroll.endSuccess(res.data.length)
if (page.num == 1) this.dataList = [];
this.dataList = this.dataList.concat(res.data,);
this.dataList = this.dataList.concat(res.data, );
}).catch(err => {
this.mescroll.endErr()
})
@ -91,7 +93,7 @@
</script>
<style lang="scss">
page{
background: #ffffff;
}
page {
background: #ffffff;
}
</style>

View File

@ -29,43 +29,24 @@
</cu-swiper> -->
<!-- -->
<block v-if="!playShow">
<swiper
class="swipers h-750rpx"
circular="true"
autoplay="true"
indicator-dots="true"
indicator-color="#ffffff"
indicator-active-color="#82848a"
>
<swiper class="swipers h-750rpx" circular="true" autoplay="true" indicator-dots="true"
indicator-color="#ffffff" indicator-active-color="#82848a">
<swiper-item class="flex justify-center w-full h-full" v-for="(item, index) in bannerList" :key="index">
<view class="w-full h-full relative">
<image
v-if="item.type == 'video'"
class="w-90rpx h-90rpx translate-center z-40"
src="/static/images/icon_play.png"
@tap="playVideo"
/>
<image class="w-full h-full" :src="`${item.image}?x-oss-process=image/resize,w_750/quality,q_90`" mode="aspectFill" />
<image v-if="item.type == 'video'" class="w-90rpx h-90rpx translate-center z-40"
src="/static/images/icon_play.png" @tap="playVideo" />
<image class="w-full h-full" :src="`${item.image}?x-oss-process=image/resize,w_750/quality,q_90`"
mode="aspectFill" />
</view>
</swiper-item>
</swiper>
</block>
<!-- -->
<view class="relative" v-else>
<video
object-fit="object-fit"
class="w-750rpx h-750rpx"
:enable-progress-gesture="false"
id="myVideo"
v-if="media.length"
:src="`${media[0]}`"
controls
>
<cover-image
@click="pauseVideo"
class="absolute right-30rpx top-30rpx w-60rpx h-60rpx"
src="/static/images/app/app_update_close.png"
></cover-image>
<video class="w-750rpx h-750rpx" :enable-progress-gesture="false" id="myVideo" v-if="media.length"
:src="`${media[0]}`" controls>
<cover-image @click="pauseVideo" class="absolute right-30rpx top-30rpx w-60rpx h-60rpx"
src="/static/images/app/app_update_close.png"></cover-image>
</video>
</view>
@ -74,9 +55,8 @@
<view class="text-txBase text-lg pt-base">{{ detail.name }}</view>
<view class="flex items-center mt-10rpx" v-if="!isPoints">
<!-- <view class="text-md text-txGray">{{ detail.subtitle }}</view> -->
<view class="px-13rpx bg-primary bg-opacity-20 text-md rounded-10rpx text-primary" v-if="detail.sales_value"
>成长值:{{ detail.sales_value }}</view
>
<view class="px-13rpx bg-primary bg-opacity-20 text-md rounded-10rpx text-primary"
v-if="detail.sales_value">成长值:{{ detail.sales_value }}</view>
</view>
<view class="flex items-center justify-between">
<view class="text-txBase text-md flex items-center">
@ -88,12 +68,8 @@
</view>
<view class="flex items-center mt-base">
<!-- <image class="w-36rpx h-36rpx" src="/static/images/user/collection.png" mode=""></image> -->
<u-icon
:color="products.is_collected ? '#FC8720' : ''"
size="36"
:name="products.is_collected ? 'star-fill' : 'star'"
@tap="onCollection"
></u-icon>
<u-icon :color="products.is_collected ? '#FC8720' : ''" size="36"
:name="products.is_collected ? 'star-fill' : 'star'" @tap="onCollection"></u-icon>
<view class="text-txBase text-md ml-10rpx leading-0">收藏</view>
</view>
</view>
@ -103,7 +79,8 @@
</view>
</view>
<!-- -->
<view class="flex items-center justify-between bg-white px-41rpx py-32rpx" @tap="showSpecFun(0)" v-if="specs.length && !isPoints">
<view class="flex items-center justify-between bg-white px-41rpx py-32rpx" @tap="showSpecFun(0)"
v-if="specs.length && !isPoints">
<view class="flex items-center text-txBase text-md">
<view class="font-extrabold">选择</view>
<view class="ml-base">{{ activeSkuText }}</view>
@ -179,26 +156,19 @@
<view class="flex pb-20rpx items-center">
<view class="flex rtl">
<view
class="rounded-full w-90rpx h-90rpx bg-hex-cacaca border border-4rpx border-hex-fff box-content flex items-center justify-center"
>
class="rounded-full w-90rpx h-90rpx bg-hex-cacaca border border-4rpx border-hex-fff box-content flex items-center justify-center">
<u-icon name="plus" color="#ffffff" size="40"></u-icon>
</view>
<view
class="rounded-full w-90rpx h-90rpx bg-rose-100 border border-4rpx border-hex-fff box-content"
v-for="(item, index) in bargainLogs"
:key="index"
:class="{ '-ml-30rpx': index != bargainLogs.length - 1 }"
>
<view class="rounded-full w-90rpx h-90rpx bg-rose-100 border border-4rpx border-hex-fff box-content"
v-for="(item, index) in bargainLogs" :key="index"
:class="{ '-ml-30rpx': index != bargainLogs.length - 1 }">
<u-avatar :size="90" :src="item.avatar"></u-avatar>
</view>
</view>
<view class="flex-1"></view>
<view class="">
<view
class="bg-hex-e81300 rounded-8rpx px-40rpx h-60rpx leading-60rpx text-white text-30rpx"
@click="$u.routeAuth('/pages/bargain/invite', { skuId: skuId })"
>邀请好友</view
>
<view class="bg-hex-e81300 rounded-8rpx px-40rpx h-60rpx leading-60rpx text-white text-30rpx"
@click="$u.routeAuth('/pages/bargain/invite', { skuId: skuId })">邀请好友</view>
</view>
</view>
</view>
@ -263,7 +233,7 @@
</block>
</u-table>
</view>
<u-parse :html="detailHtml" style="font-size:0;width: 100%;" :tagStyle="style"></u-parse>
<u-parse :html="detailHtml" style="font-size:0;width: 100%;" :tagStyle="style"></u-parse>
</view>
<!-- 购物须知 -->
<view class="mt-base bg-white">
@ -280,25 +250,26 @@
<!-- 底部导航栏 -->
<view class="flex items-center fixed right-0 left-0 bottom-0 bottom w-full bg-white shadow cu-bar tabbar">
<block v-if="isPoints">
<view class="mx-base bg-bgSubtitle rounded-lg w-full h-66rpx text-center leading-66rpx text-md text-white" @click="onDHClick"></view>
<view class="mx-base bg-bgSubtitle rounded-lg w-full h-66rpx text-center leading-66rpx text-md text-white"
@click="onDHClick">兑换</view>
</block>
<block v-else>
<view class="w-300rpx flex justify-around ml-20rpx">
<view class="flex items-center justify-center h-full flex-col flex-1" @tap="$u.routeAuth('/pages/auxiliary_cart/index')">
<view class="flex items-center justify-center h-full flex-col flex-1"
@tap="$u.routeAuth('/pages/auxiliary_cart/index')">
<view class="relative w-48rpx h-48rpx flex justify-center items-center">
<image class="w-full h-full" src="/static/images/cart/short-cart.png" mode="scaleToFill" />
<view
v-if="cartList.length"
class="absolute -right-24rpx -top-10rpx leading-36rpx text-sm text-bgSubtitle bg-white text-center w-36rpx h-36rpx border border-b border-txBorder border-txbordergSubtitle rounded-full"
>
<view v-if="cartList.length"
class="absolute -right-24rpx -top-10rpx leading-36rpx text-sm text-bgSubtitle bg-white text-center w-36rpx h-36rpx border border-b border-txBorder border-txbordergSubtitle rounded-full">
{{ cartList.length }}
</view>
</view>
<view class="text-26rpx mt-10rpx">购物车</view>
</view>
<!-- #ifndef MP-WEIXIN -->
<view class="flex items-center justify-center flex-col h-full flex-1" @tap="$u.route(`/pages/web_view/index?url=${service}`)">
<view class="flex items-center justify-center flex-col h-full flex-1"
@tap="$u.route(`/pages/web_view/index?url=${service}`)">
<view class="w-48rpx h-48rpx flex justify-center items-center">
<u-icon name="kefu-ermai" color="#000" size="48"></u-icon>
</view>
@ -306,7 +277,8 @@
</view>
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<button open-type="contact" hover-class="none" class="cu-btn flex items-center justify-center flex-col h-full flex-1">
<button open-type="contact" hover-class="none"
class="cu-btn flex items-center justify-center flex-col h-full flex-1">
<view class="w-48rpx h-48rpx flex justify-center items-center">
<u-icon name="kefu-ermai" color="#000" size="48"></u-icon>
</view>
@ -325,12 +297,11 @@
</view>
<view class="flex items-center justify-center flex-1">
<view class="bg-primary rounded-lg w-180rpx h-66rpx text-center leading-66rpx text-md text-white" @tap="showSpecFun(1)"
>加入购物车</view
>
<view class="ml-base bg-bgSubtitle rounded-lg w-180rpx h-66rpx text-center leading-66rpx text-md text-white" @tap="showSpecFun(2)"
>立即购买</view
>
<view class="bg-primary rounded-lg w-180rpx h-66rpx text-center leading-66rpx text-md text-white"
@tap="showSpecFun(1)">加入购物车</view>
<view
class="ml-base bg-bgSubtitle rounded-lg w-180rpx h-66rpx text-center leading-66rpx text-md text-white"
@tap="showSpecFun(2)">立即购买</view>
</view>
</block>
</view>
@ -345,20 +316,10 @@
<u-skeleton :loading="isFirstLoading" :animation="true" bgColor="#FFF"></u-skeleton>
<spec-popup
:loading="loading"
:specs="specs"
:sku="detail"
v-model="show"
:quota-used="number"
:show-cart="popupType == 1 || popupType == 0"
:show-buy="popupType == 2 || popupType == 0"
:show-confirm="popupType == 3"
@stepper-change="onChangeNumber"
@sku-selected="onChangeSku"
@buy-clicked="onBuy"
@add-cart="onAddCart"
>
<spec-popup :loading="loading" :specs="specs" :sku="detail" v-model="show" :quota-used="number"
:show-cart="popupType == 1 || popupType == 0" :show-buy="popupType == 2 || popupType == 0"
:show-confirm="popupType == 3" @stepper-change="onChangeNumber" @sku-selected="onChangeSku" @buy-clicked="onBuy"
@add-cart="onAddCart">
</spec-popup>
<!-- 分享弹窗 -->
<sharePopup v-model="shareShow" :goods="detail" :goodsImage="goodsImage"></sharePopup>
@ -366,368 +327,372 @@
</template>
<script>
import comment from '@/components/comment/comment';
import sharePopup from './components/share-popup.vue';
import { mapGetters, mapActions } from 'vuex';
export default {
components: {
comment,
sharePopup,
},
data() {
return {
bargainDetail: {},
showShrough: false, //
// service: process.env.VUE_APP_SERVICE,
isFirstLoading: true,
isNull: false,
loading: false,
// SPU-ID
productId: '',
// SKU-ID
skuId: '',
number: 1,
products: {},
show: false,
popupType: '',
goodsError: '',
title: '',
playShow: false,
shareShow: false,
goodsImage: '', //
style:{
p: 'font-size:0',
span: 'font-size: 0',
img:'display:block;min-width:100%'
}
};
},
computed: {
...mapGetters(['cartList']),
user() {
return this.$store.getters.user ?? {};
import comment from '@/components/comment/comment';
import sharePopup from './components/share-popup.vue';
import {
mapGetters,
mapActions
} from 'vuex';
export default {
components: {
comment,
sharePopup,
},
service() {
const clien = process.env.VUE_APP_SERVICE;
const user = this.$store.getters.user ?? {};
const phone = user?.phone;
const name = user?.nickname ?? phone ?? '访客';
return `${clien}?u_cust_name=${name}&u_cust_phone=${phone}&u_cust_id=${phone}`;
},
bargainLogs() {
return this.bargainDetail?.logs?.reverse() ?? [];
},
detail() {
return this.products?.sku ?? {};
},
//
features() {
return this.products?.features ?? [];
},
//banner
images() {
return this.detail?.images ?? [];
},
media() {
const media = this.detail?.media;
return media ? [media] : [];
},
bannerList() {
const imgs = this.images.map((e) => {
return {
type: 'image',
image: e,
};
});
const videos = this.media.map((e) => {
return {
type: 'video',
image: this.detail.cover,
video: e,
};
});
return videos.concat(imgs);
},
specs() {
return this.products?.spu_specs ?? [];
},
attrs() {
return this.detail?.attrs ?? [];
},
detailHtml() {
return this.detail?.description ?? '';
},
//sku
activeSku() {
const sku = this.specs.reduce((arr, pr) => {
if (pr.items.some((e) => e.selected)) {
const item = pr.items.find((e) => e.selected);
arr.push(item);
data() {
return {
bargainDetail: {},
showShrough: false, //
// service: process.env.VUE_APP_SERVICE,
isFirstLoading: true,
isNull: false,
loading: false,
// SPU-ID
productId: '',
// SKU-ID
skuId: '',
number: 1,
products: {},
show: false,
popupType: '',
goodsError: '',
title: '',
playShow: false,
shareShow: false,
goodsImage: '', //
style: {
p: 'font-size:0',
span: 'font-size: 0',
img: 'display:block;min-width:100%'
}
return arr;
}, []);
return sku;
};
},
//sku
activeSkuText() {
if (this.activeSku.length) return `${this.activeSku.map((e) => e.name).join(',')};数量:${this.number}`;
return '请选择规格';
computed: {
...mapGetters(['cartList']),
user() {
return this.$store.getters.user ?? {};
},
service() {
const clien = process.env.VUE_APP_SERVICE;
const user = this.$store.getters.user ?? {};
const phone = user?.phone;
const name = user?.nickname ?? phone ?? '访客';
return `${clien}?u_cust_name=${name}&u_cust_phone=${phone}&u_cust_id=${phone}`;
},
bargainLogs() {
return this.bargainDetail?.logs?.reverse() ?? [];
},
detail() {
return this.products?.sku ?? {};
},
//
features() {
return this.products?.features ?? [];
},
//banner
images() {
return this.detail?.images ?? [];
},
media() {
const media = this.detail?.media;
return media ? [media] : [];
},
bannerList() {
const imgs = this.images.map((e) => {
return {
type: 'image',
image: e,
};
});
const videos = this.media.map((e) => {
return {
type: 'video',
image: this.detail.cover,
video: e,
};
});
return videos.concat(imgs);
},
specs() {
return this.products?.spu_specs ?? [];
},
attrs() {
return this.detail?.attrs ?? [];
},
detailHtml() {
return this.detail?.description ?? '';
},
//sku
activeSku() {
const sku = this.specs.reduce((arr, pr) => {
if (pr.items.some((e) => e.selected)) {
const item = pr.items.find((e) => e.selected);
arr.push(item);
}
return arr;
}, []);
return sku;
},
//sku
activeSkuText() {
if (this.activeSku.length) return `${this.activeSku.map((e) => e.name).join(',')};数量:${this.number}`;
return '请选择规格';
},
//
isPoints() {
return this.detail.redeem_points > 0
},
priceText() {
let price = ''
if (this.detail.sell_price > 0) price += `${parseFloat(this.detail.sell_price)}`
if (this.detail.sell_price > 0 && this.detail.redeem_points > 0) price += '+'
if (this.detail.redeem_points > 0) price += `${this.detail.redeem_points} 积分`
return price
}
},
//
isPoints(){
return this.detail.redeem_points > 0
onLoad({
skuId,
showShrough
}) {
if (showShrough) {
this.showShrough = showShrough;
}
this.productId = skuId;
this.getProducts();
this.$store.dispatch('goods/getCartList');
},
priceText(){
let price = ''
if(this.detail.sell_price > 0) price+=`${parseFloat(this.detail.sell_price)}`
if(this.detail.sell_price > 0 && this.detail.redeem_points > 0) price+='+'
if(this.detail.redeem_points > 0) price+=`${this.detail.redeem_points} 积分`
return price
}
},
onLoad({ skuId, showShrough }) {
if (showShrough) {
this.showShrough = showShrough;
}
this.productId = skuId;
this.getProducts();
this.$store.dispatch('goods/getCartList');
},
//
onShareAppMessage(res) {
if (res.from === 'button') {
//
this.shareShow = false;
}
let code = this.user.code ? this.user.code : '';
let shareObj = {
title: this.detail.name,
path: `/pages/product_details/index?skuId=${this.productId}&invite_code=${code}`,
imageUrl: this.detail.cover,
};
return shareObj;
},
methods: {
onDHClick(){
const params = {
goods: [
{
//
onShareAppMessage(res) {
if (res.from === 'button') {
//
this.shareShow = false;
}
let code = this.user.code ? this.user.code : '';
let shareObj = {
title: this.detail.name,
path: `/pages/product_details/index?skuId=${this.productId}&invite_code=${code}`,
imageUrl: this.detail.cover,
};
return shareObj;
},
methods: {
onDHClick() {
const params = {
goods: [{
sku_id: this.skuId,
num: 1,
}, ],
type: 'points'
};
this.$u.routeAuth('/pages/confirm_order/confirm_order?data=' + encodeURIComponent(JSON.stringify(params)));
},
//
getLocal(path) {
uni.getImageInfo({
src: path,
success: (res) => {
this.goodsImage = res.path;
},
],
type: 'points'
};
this.$u.routeAuth('/pages/confirm_order/confirm_order?data=' + encodeURIComponent(JSON.stringify(params)));
},
//
getLocal(path) {
uni.getImageInfo({
src: path,
success: (res) => {
this.goodsImage = res.path;
},
complete: (copy) => {},
});
},
//
getShare() {
if (!this.isLogin) return this.$u.routeLogin();
this.shareShow = true;
},
//app
shareApp() {
let code = this.user.code ? this.user.code : '';
uni.share({
provider: 'weixin',
scene: 'WXSceneSession',
type: 0,
href: `https://wap.zichunsheng.cn/register?code=${code}`,
title: this.detail.name,
summary: '我正在使用积趣自然图书馆,赶紧跟我一起来体验吧!',
imageUrl: `${this.detail.cover}?x-oss-process=image/resize,w_80/quality,q_90`,
success: (res) => {},
});
},
playVideo() {
this.playShow = true;
setTimeout(() => {
complete: (copy) => {},
});
},
//
getShare() {
if (!this.isLogin) return this.$u.routeLogin();
this.shareShow = true;
},
//app
shareApp() {
let code = this.user.code ? this.user.code : '';
uni.share({
provider: 'weixin',
scene: 'WXSceneSession',
type: 0,
href: `https://wap.zichunsheng.cn/register?code=${code}`,
title: this.detail.name,
summary: '我正在使用积趣自然图书馆,赶紧跟我一起来体验吧!',
imageUrl: `${this.detail.cover}?x-oss-process=image/resize,w_80/quality,q_90`,
success: (res) => {},
});
},
playVideo() {
this.playShow = true;
setTimeout(() => {
const v = uni.createVideoContext('myVideo', this);
v.play();
}, 100);
},
pauseVideo() {
const v = uni.createVideoContext('myVideo', this);
v.play();
}, 100);
},
pauseVideo() {
const v = uni.createVideoContext('myVideo', this);
v.pause();
this.playShow = false;
},
...mapActions({
getCartList: 'goods/getCartList',
}),
//
getTitle(title) {
this.title = title;
uni.setNavigationBarTitle({
title: title,
});
},
v.pause();
this.playShow = false;
},
...mapActions({
getCartList: 'goods/getCartList',
}),
//
getTitle(title) {
this.title = title;
uni.setNavigationBarTitle({
title: title,
});
},
//
onBuy() {
const params = {
goods: [
{
//
onBuy() {
const params = {
goods: [{
sku_id: this.skuId,
num: this.number,
},
],
};
this.show = false;
this.$u.routeAuth('/pages/confirm_order/confirm_order?data=' + encodeURIComponent(JSON.stringify(params)));
},
//
async onAddCart(e) {
const { skuId, number } = this;
try {
await this.$store.dispatch(
'goods/addCart',
{
skuId,
number,
},
{
custom: {
loading: true,
},
},
);
this.$u.toast('添加购物车成功');
}, ],
};
this.show = false;
} catch (error) {
// console.log(error);
}
},
//
async getProducts() {
try {
this.loading = true;
const resData = await this.$api.get(`/v1/product/products/${this.productId}`);
this.products = resData;
this.skuId = this.products?.sku.id
this.$u.routeAuth('/pages/confirm_order/confirm_order?data=' + encodeURIComponent(JSON.stringify(params)));
},
//
async onAddCart(e) {
const {
skuId,
number
} = this;
try {
await this.$store.dispatch(
'goods/addCart', {
skuId,
number,
}, {
custom: {
loading: true,
},
},
);
this.$u.toast('添加购物车成功');
this.show = false;
} catch (error) {
// console.log(error);
}
},
//
async getProducts() {
try {
this.loading = true;
const resData = await this.$api.get(`/v1/product/products/${this.productId}`);
this.products = resData;
this.skuId = this.products?.sku.id
if (resData?.sku?.is_bargaing) {
this.bargainOrderLog();
if (resData?.sku?.is_bargaing) {
this.bargainOrderLog();
}
//
this.getTitle(resData.sku.name);
//
this.getLocal(resData.sku.cover);
} catch (error) {
if (error != 404) {
this.isNull = true;
}
// console.log(error);
} finally {
this.loading = false;
this.isFirstLoading = false;
}
//
this.getTitle(resData.sku.name);
//
this.getLocal(resData.sku.cover);
} catch (error) {
if (error != 404) {
this.isNull = true;
}
// console.log(error);
} finally {
this.loading = false;
this.isFirstLoading = false;
}
},
//
async bargainOrderLog() {
const data = await this.$api.get(`/v1/bargain-order/sku/${this.skuId}`);
this.bargainDetail = data;
},
showSpecFun(type) {
if (!this.isLogin) return this.$u.routeLogin();
this.popupType = type;
this.show = true;
},
//
onChangeNumber(e) {
this.number = e;
},
//sku
onChangeSku(e) {
this.skuId = e.sku_id;
this.getProdutsku();
},
//
async getProdutsku() {
try {
this.loading = true;
const resData = await this.$api.get(`/v1/product/sku/${this.skuId}`);
this.products = resData;
if (resData?.sku?.is_bargaing) {
this.bargainOrderLog();
}
//
this.getTitle(resData.sku.name);
//
this.getLocal(resData.sku.cover);
} catch (error) {
if (error != 404) {
this.isNull = true;
}
// console.log(error);
} finally {
this.loading = false;
this.isFirstLoading = false;
}
},
//
//
onCollection() {
this.$u.throttle(async () => {
},
//
async bargainOrderLog() {
const data = await this.$api.get(`/v1/bargain-order/sku/${this.skuId}`);
this.bargainDetail = data;
},
showSpecFun(type) {
if (!this.isLogin) return this.$u.routeLogin();
if (this.products.is_collected) {
await this.$api.post(`/v1/product/products/${this.skuId}/uncollect`);
this.products.is_collected = false;
this.$u.toast('取消收藏');
} else {
await this.$api.post(`/v1/product/products/${this.skuId}/collect`);
this.products.is_collected = true;
this.$u.toast('收藏成功');
this.popupType = type;
this.show = true;
},
//
onChangeNumber(e) {
this.number = e;
},
//sku
onChangeSku(e) {
this.skuId = e.sku_id;
this.getProdutsku();
},
//
async getProdutsku() {
try {
this.loading = true;
const resData = await this.$api.get(`/v1/product/sku/${this.skuId}`);
this.products = resData;
if (resData?.sku?.is_bargaing) {
this.bargainOrderLog();
}
//
this.getTitle(resData.sku.name);
//
this.getLocal(resData.sku.cover);
} catch (error) {
if (error != 404) {
this.isNull = true;
}
// console.log(error);
} finally {
this.loading = false;
this.isFirstLoading = false;
}
}, 1000);
},
//
//
onCollection() {
this.$u.throttle(async () => {
if (!this.isLogin) return this.$u.routeLogin();
if (this.products.is_collected) {
await this.$api.post(`/v1/product/products/${this.skuId}/uncollect`);
this.products.is_collected = false;
this.$u.toast('取消收藏');
} else {
await this.$api.post(`/v1/product/products/${this.skuId}/collect`);
this.products.is_collected = true;
this.$u.toast('收藏成功');
}
}, 1000);
},
jump(url) {
uni.navigateTo({
url: '/pages' + url,
});
},
//
close(e) {
this.show = !e;
},
},
jump(url) {
uni.navigateTo({
url: '/pages' + url,
});
},
//
close(e) {
this.show = !e;
},
},
};
};
</script>
<style lang="scss" scoped>
.border-hex-fff {
border: 1px solid #fff !important;
}
.share-btn::after {
border: none;
}
.border-hex-fff {
border: 1px solid #fff !important;
}
.shadow {
box-shadow: 0px -4rpx 10rpx rgba(0, 0, 0, 0.11);
}
.share-btn::after {
border: none;
}
.shadowRight {
box-shadow: 2rpx 0px 5rpx rgba(0, 0, 0, 0.12);
}
.shadow {
box-shadow: 0px -4rpx 10rpx rgba(0, 0, 0, 0.11);
}
.badge {
@apply bg-badge;
}
.shadowRight {
box-shadow: 2rpx 0px 5rpx rgba(0, 0, 0, 0.12);
}
.fontFam {
/* #ifdef APP-PLUS */
font-family: '宋体';
/* #endif */
}
.badge {
@apply bg-badge;
}
.fontFam {
/* #ifdef APP-PLUS */
font-family: '宋体';
/* #endif */
}
</style>

View File

@ -10,11 +10,12 @@ const ALLACCOUNTS = "app_accounts"
const getDefaultState = () => {
return {
token: uni.getStorageSync(TOKEN),
user: null,//用户信息
news_num: 0,//消息数
order_count: null,//订单数量
history: uni.getStorageSync(HISTORY) || [],//历史搜索
allaccounts: uni.getStorageSync(ALLACCOUNTS) || [],//所有账号
// token: '1104|nAMfPQH3HTnb4Y6p06mgIbPjPNC9Hqb24sbglwfQ',
user: null, //用户信息
news_num: 0, //消息数
order_count: null, //订单数量
history: uni.getStorageSync(HISTORY) || [], //历史搜索
allaccounts: uni.getStorageSync(ALLACCOUNTS) || [], //所有账号
}
}
@ -26,16 +27,16 @@ const mutations = {
Object.assign(state, getDefaultState())
},
async LOGIN(state, value) {
await this.commit('user/SET_TOKEN',value)
await this.dispatch('user/getUserInfo',false)
},
LOGOUT(){
await this.commit('user/SET_TOKEN', value)
await this.dispatch('user/getUserInfo', false)
},
LOGOUT() {
return this.dispatch('user/resetToken')
},
// 登录
async SET_TOKEN(state, value) {
state.token = value
await uni.setStorageSync(TOKEN, value);
await uni.setStorageSync(TOKEN, value);
},
//获取用户信息
SET_USERINFO(state, value) {
@ -52,7 +53,9 @@ const mutations = {
if (state.history.length == 0) {
state.history.unshift(value)
} else {
let Index = state.history.findIndex(item => { return item == value })
let Index = state.history.findIndex(item => {
return item == value
})
if (Index == -1) {
state.history.unshift(value)
}
@ -71,7 +74,9 @@ const mutations = {
},
//修改资料后改变用户信息
SET_REFRESH(state, value) {
let Index = state.allaccounts.findIndex(item => { return item.phone == value.phone })
let Index = state.allaccounts.findIndex(item => {
return item.phone == value.phone
})
if (Index != -1) {
state.allaccounts[Index].phone = value.phone
state.allaccounts[Index].avatar = value.avatar
@ -97,7 +102,10 @@ const actions = {
commit,
state,
dispatch
}, { form, switchAllaccounts }) {
}, {
form,
switchAllaccounts
}) {
return new Promise((resolve, reject) => {
http.post('/v1/login', form, {
@ -107,12 +115,15 @@ const actions = {
}).then(({
token
}) => {
if(switchAllaccounts && state.allaccounts.length==0){
if (switchAllaccounts && state.allaccounts.length == 0) {
const tempUserInfo = {
...Object.assign({},state.user),
token:state.token,
...Object.assign({}, state.user),
token: state.token,
}
dispatch('getAccounts', { info:tempUserInfo, switchAllaccounts })
dispatch('getAccounts', {
info: tempUserInfo,
switchAllaccounts
})
}
resolve(token)
commit('SET_TOKEN', token)
@ -150,7 +161,11 @@ const actions = {
},
//获取用户信息
getUserInfo({ commit, state, dispatch }, switchAllaccounts) {
getUserInfo({
commit,
state,
dispatch
}, switchAllaccounts) {
return new Promise((resolve, reject) => {
if (!state.token) return
@ -158,16 +173,29 @@ const actions = {
custom: {
silence: true
}
}).then(({ phone, user_info, is_vip, wallet, balance,vip_expired }) => {
}).then(({
phone,
user_info,
is_vip,
wallet,
balance,
vip_expired
}) => {
let user = user_info
user.phone = phone
user.is_vip = is_vip
user.wallet = wallet
user.balance = balance
user.vip_expired=vip_expired
user.vip_expired = vip_expired
commit('SET_USERINFO', user)
dispatch('bindCid')
dispatch('getAccounts', { info: { ...user, token: state.token }, switchAllaccounts })
dispatch('getAccounts', {
info: {
...user,
token: state.token
},
switchAllaccounts
})
resolve(user)
}).catch(err => {
reject(err)
@ -175,7 +203,13 @@ const actions = {
})
},
getAccounts({ commit, state }, { info, switchAllaccounts = false }) {
getAccounts({
commit,
state
}, {
info,
switchAllaccounts = false
}) {
const obj = {
avatar: info.avatar,
@ -194,7 +228,9 @@ const actions = {
}
commit('SET_ACCOUNTS', all)
},
resetToken({ commit }) {
resetToken({
commit
}) {
return new Promise(resolve => {
uni.removeStorageSync(TOKEN);
commit('RESET_STATE')
@ -204,19 +240,30 @@ const actions = {
bindCid() {
// #ifdef APP-PLUS
const cid = plus.push.getClientInfo()?.clientid
http.post('/v1/push-bind-uni', { cid }, { custom: { toast: false } })
http.post('/v1/push-bind-uni', {
cid
}, {
custom: {
toast: false
}
})
// #endif
},
//异步获取消息未读数
getNewsNum({ commit, state }) {
getNewsNum({
commit,
state
}) {
return new Promise((resolve, reject) => {
if (!state.token) return
http.get('/v1/messages/wait-read-num', {}, {
custom: {
silence: true
}
}).then(({ num }) => {
}).then(({
num
}) => {
commit('SET_NEWS', num)
resolve(num)
}).catch(err => {
@ -225,7 +272,10 @@ const actions = {
})
},
//获取订单数量
getOrderNum({ commit, state }) {
getOrderNum({
commit,
state
}) {
return new Promise((resolve, reject) => {
if (!state.token) return
http.get('/v1/order/statistics').then(res => {