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> <template>
<view class="px-30rpx pt-20rpx"> <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 class="text-center">返利</view>
<view class="text-center">状态</view> <view class="text-center">状态</view>
</view> </view>
<mescroll-body :height="height" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" <mescroll-body :height="height" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
:up="upOption"> :down="downOption" :up="upOption">
<block v-for="(item,index) in dataList" :key="index"> <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 line-1 ">{{item.created_at*1000 | date('yyyy-mm-dd')}}</view>
<view class="text-center price-text">{{item.money}}</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> </view>
<u-line></u-line> <u-line></u-line>
</block> </block>
@ -37,8 +39,8 @@
dataList: [], // dataList: [], //
}; };
}, },
filters:{ filters: {
StatusText(value){ StatusText(value) {
const status = [{ const status = [{
value: 0, value: 0,
label: '待付款' label: '待付款'
@ -56,7 +58,7 @@
return obj?.label ?? value return obj?.label ?? value
} }
}, },
computed:{ computed: {
height() { height() {
const { const {
windowHeight, windowHeight,
@ -81,7 +83,7 @@
}).then(res => { }).then(res => {
this.mescroll.endSuccess(res.data.length) this.mescroll.endSuccess(res.data.length)
if (page.num == 1) this.dataList = []; if (page.num == 1) this.dataList = [];
this.dataList = this.dataList.concat(res.data,); this.dataList = this.dataList.concat(res.data, );
}).catch(err => { }).catch(err => {
this.mescroll.endErr() this.mescroll.endErr()
}) })
@ -91,7 +93,7 @@
</script> </script>
<style lang="scss"> <style lang="scss">
page{ page {
background: #ffffff; background: #ffffff;
} }
</style> </style>

View File

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

View File

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