Merge branch 'master' of https://git.dayouqiantu.cn/uniapp/yshop-uniapp
This commit is contained in:
@ -13,7 +13,7 @@
|
||||
- uni会自动打开微信开发者工具并且打开uni的项目
|
||||
|
||||
## 注意事项
|
||||
- 目前并不支持H5运行,需要运行H5模式的,请自行调整兼容
|
||||
- uniapp v3.1版本已经兼容h5,另外yshop有自己的H5,uniappv3.1以下版本未对H5端进行处理,如果需要请自行兼容。
|
||||
- manifest.json 中可以配置uni项目的一些信息
|
||||
- 打开manifest.json可配置小程序的 appid
|
||||
- 由于需要兼容app,公共样式由 main.js 迁移到了 App.vue,公共样式请在App.vue中进行编辑
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -2467,7 +2467,7 @@ page {
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
border-bottom: 1rpx solid #f5f5f5;
|
||||
z-index: 999;
|
||||
z-index: 99;
|
||||
height: 1rpx;
|
||||
|
||||
}
|
||||
|
||||
@ -1,65 +1,67 @@
|
||||
<template>
|
||||
<view class="time">
|
||||
<text v-if="rtipText">{{ rtipText }}</text>
|
||||
<text class="styleAll" v-if="risDay === true">{{ rday }}</text>
|
||||
<text class="timeTxt" v-if="rdayText">{{ rdayText }}</text>
|
||||
{{ tipText }}
|
||||
<text class="styleAll" v-if="isDay === true">{{ day }}</text>
|
||||
<text class="timeTxt">{{ dayText }}</text>
|
||||
<text class="styleAll">{{ hour }}</text>
|
||||
<text class="timeTxt" v-if="rhourText">{{ rhourText }}</text>
|
||||
<text class="timeTxt">{{ hourText }}</text>
|
||||
<text class="styleAll">{{ minute }}</text>
|
||||
<text class="timeTxt" v-if="rminuteText">{{ rminuteText }}</text>
|
||||
<text class="timeTxt">{{ minuteText }}</text>
|
||||
<text class="styleAll">{{ second }}</text>
|
||||
<text class="timeTxt" v-if="rsecondText">{{ rsecondText }}</text>
|
||||
<text class="timeTxt">{{ secondText }}</text>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: "CountDown",
|
||||
props: [
|
||||
props: {
|
||||
//距离开始提示文字
|
||||
'tipText',
|
||||
'dayText',
|
||||
'hourText',
|
||||
'minuteText',
|
||||
'secondText',
|
||||
'datatime',
|
||||
'isDay'
|
||||
],
|
||||
tipText: {
|
||||
type: String,
|
||||
default: "倒计时"
|
||||
},
|
||||
dayText: {
|
||||
type: String,
|
||||
default: "天"
|
||||
},
|
||||
hourText: {
|
||||
type: String,
|
||||
default: "时"
|
||||
},
|
||||
minuteText: {
|
||||
type: String,
|
||||
default: "分"
|
||||
},
|
||||
secondText: {
|
||||
type: String,
|
||||
default: "秒"
|
||||
},
|
||||
datatime: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
isDay: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
},
|
||||
data: function () {
|
||||
return {
|
||||
day: "00",
|
||||
hour: "00",
|
||||
minute: "00",
|
||||
second: "00",
|
||||
rtipText: "倒计时",
|
||||
rdayText: "天",
|
||||
rhourText: "时",
|
||||
rminuteText: "分",
|
||||
rsecondText: "秒",
|
||||
rdatatime: 0,
|
||||
risDay: true
|
||||
second: "00"
|
||||
};
|
||||
},
|
||||
created: function () {
|
||||
// this.show_time();
|
||||
},
|
||||
mounted: function() {
|
||||
this.rtipText = this.$props.tipText;
|
||||
this.rdayText = this.$props.dayText;
|
||||
this.rhourText = this.$props.hourText;
|
||||
this.rminuteText = this.$props.minuteText;
|
||||
this.rsecondText = this.$props.secondText;
|
||||
this.rdatatime = this.$props.datatime;
|
||||
this.risDay = this.$props.isDay;
|
||||
this.show_time();
|
||||
},
|
||||
mounted: function () {},
|
||||
methods: {
|
||||
show_time: function () {
|
||||
let that = this;
|
||||
this.runTime();
|
||||
setInterval(this.runTime, 1000);
|
||||
},
|
||||
runTime() {
|
||||
let that = this;
|
||||
|
||||
function runTime() {
|
||||
//时间函数
|
||||
let intDiff = that.datatime - Date.parse(new Date()) / 1000; //获取数据中的时间戳的时间差;
|
||||
let day = 0,
|
||||
@ -94,6 +96,9 @@ export default {
|
||||
that.second = "00";
|
||||
}
|
||||
}
|
||||
runTime();
|
||||
setInterval(runTime, 1000);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
@ -5,4 +5,3 @@
|
||||
export const VUE_APP_API_URL = 'https://h5api.xinxintuan.co/api';
|
||||
// export const VUE_APP_API_URL = 'https://h5api.xinxintuan.co/api';
|
||||
export const VUE_APP_RESOURCES_URL = 'https://wx.yixiang.co/static';
|
||||
|
||||
|
||||
@ -86,9 +86,11 @@ const LOGINTYPE = "loginType";
|
||||
let instance;
|
||||
let wechatObj;
|
||||
let appId
|
||||
let wechatLoading = false
|
||||
|
||||
export function wechat() {
|
||||
console.log('初始化微信配置')
|
||||
wechatLoading = false
|
||||
return new Promise((resolve, reject) => {
|
||||
if (instance) return resolve(instance);
|
||||
getWechatConfig()
|
||||
@ -107,12 +109,17 @@ export function wechat() {
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error)
|
||||
reject(error)
|
||||
uni.showToast({
|
||||
title: error,
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
reject()
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
reject(err);
|
||||
reject();
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -122,9 +129,8 @@ export function clearAuthStatus() {
|
||||
cookie.remove(STATE_KEY);
|
||||
}
|
||||
|
||||
export function oAuth() {
|
||||
export async function oAuth() {
|
||||
console.log('处理微信授权')
|
||||
console.log('处理微信授权cookie', cookie.get("spread"))
|
||||
console.log(store)
|
||||
console.log(store.state)
|
||||
return new Promise((resolve, reject) => {
|
||||
@ -137,6 +143,8 @@ export function oAuth() {
|
||||
if (!code) {
|
||||
toAuth();
|
||||
return
|
||||
} else {
|
||||
auth(code)
|
||||
}
|
||||
resolve()
|
||||
}).catch(error => {
|
||||
@ -144,11 +152,12 @@ export function oAuth() {
|
||||
})
|
||||
}
|
||||
|
||||
export function auth(code) {
|
||||
export async function auth(code) {
|
||||
console.log('获取微信授权')
|
||||
return new Promise((resolve, reject) => {
|
||||
let loginType = cookie.get(LOGINTYPE);
|
||||
let spread = cookie.get(spread);
|
||||
let spread = cookie.get('spread');
|
||||
console.log('微信授权登录前获取spread', spread)
|
||||
wechatAuth(code, spread, loginType)
|
||||
.then(({ data }) => {
|
||||
console.log(data)
|
||||
@ -158,15 +167,22 @@ export function auth(code) {
|
||||
cookie.set(WX_AUTH, code, expires_time);
|
||||
cookie.remove(STATE_KEY);
|
||||
loginType && cookie.remove(LOGINTYPE);
|
||||
console.log('微信公众号授权登录,获取用户信息')
|
||||
store.dispatch('getUser').finally(() => {
|
||||
resolve();
|
||||
})
|
||||
})
|
||||
.catch(reject);
|
||||
}).catch(error => {
|
||||
console.log(error)
|
||||
})
|
||||
}
|
||||
|
||||
export function toAuth() {
|
||||
export async function toAuth() {
|
||||
if (wechatLoading) {
|
||||
return
|
||||
}
|
||||
wechatLoading = true
|
||||
wechat().then(wx => {
|
||||
location.href = getAuthUrl(appId);
|
||||
});
|
||||
@ -179,9 +195,9 @@ function getAuthUrl(appId) {
|
||||
|
||||
// #ifdef H5
|
||||
// #endif
|
||||
|
||||
|
||||
const redirect_uri = encodeURIComponent(`${location.origin}/pages/Loading/index?path=${encodeURIComponent(window.location.href)}`);
|
||||
cookie.set('redirect', window.location.href)
|
||||
const redirect_uri = encodeURIComponent(`${location.origin}/pages/Loading/index`);
|
||||
// const redirect_uri = encodeURIComponent(`${location.origin}/pages/Loading/index?path=${encodeURIComponent(window.location.href)}`);
|
||||
// const redirect_uri = encodeURIComponent(`${window.location.origin}${window.location.pathname}`)
|
||||
// const redirect_uri = encodeURIComponent(`${location.origin}`)
|
||||
cookie.remove(BACK_URL);
|
||||
|
||||
139
main.js
139
main.js
@ -38,14 +38,6 @@ Vue.prototype.$validator = function (rule) {
|
||||
return new schema(rule);
|
||||
};
|
||||
|
||||
// const CACHE_KEY = "clear_0.0.1";
|
||||
|
||||
// if (!cookie.has(CACHE_KEY)) {
|
||||
// cookie.clearAll();
|
||||
// cookie.set(CACHE_KEY, 1);
|
||||
// }
|
||||
|
||||
|
||||
Vue.config.productionTip = false
|
||||
App.mpType = 'app'
|
||||
Vue.prototype.$store = store
|
||||
@ -82,73 +74,7 @@ Object.defineProperty(Vue.prototype, '$yroute', {
|
||||
Vue.prototype.$VUE_APP_RESOURCES_URL = VUE_APP_RESOURCES_URL
|
||||
Vue.prototype.$VUE_APP_API_URL = VUE_APP_API_URL
|
||||
Vue.component('cu-custom', cuCustom);
|
||||
// #ifdef H5
|
||||
// H5编译的代码
|
||||
|
||||
import {
|
||||
wechat,
|
||||
clearAuthStatus,
|
||||
oAuth,
|
||||
auth,
|
||||
toAuth,
|
||||
pay,
|
||||
openAddress,
|
||||
openShareAll,
|
||||
openShareAppMessage,
|
||||
openShareTimeline,
|
||||
wechatEvevt,
|
||||
ready,
|
||||
wxShowLocation,
|
||||
} from '@/libs/wechat'
|
||||
|
||||
import { isWeixin } from '@/utils'
|
||||
|
||||
|
||||
const CACHE_KEY = "clear_0.0.1";
|
||||
|
||||
if (!cookie.has(CACHE_KEY)) {
|
||||
cookie.clearAll();
|
||||
cookie.set(CACHE_KEY, 1);
|
||||
}
|
||||
|
||||
var urlSpread = parseQuery()["spread"];
|
||||
|
||||
if (urlSpread !== undefined) {
|
||||
var spread = cookie.get("spread");
|
||||
urlSpread = parseInt(urlSpread);
|
||||
if (!Number.isNaN(urlSpread) && spread !== urlSpread) {
|
||||
cookie.set("spread", urlSpread || 0);
|
||||
} else if (spread === 0 || typeof spread !== "number") {
|
||||
cookie.set("spread", urlSpread || 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 判断是否是微信浏览器
|
||||
if (isWeixin()) {
|
||||
Vue.prototype.$deviceType = 'weixin'
|
||||
store.commit('updateDevicetype', 'weixin')
|
||||
wechat().then(() => oAuth());
|
||||
} else {
|
||||
Vue.prototype.$deviceType = 'weixinh5'
|
||||
store.commit('updateDevicetype', 'weixinh5')
|
||||
}
|
||||
|
||||
Vue.prototype.wechat = wechat
|
||||
Vue.prototype.clearAuthStatus = clearAuthStatus
|
||||
Vue.prototype.oAuth = oAuth
|
||||
Vue.prototype.auth = auth
|
||||
Vue.prototype.toAuth = toAuth
|
||||
Vue.prototype.pay = pay
|
||||
Vue.prototype.openAddress = openAddress
|
||||
Vue.prototype.openShareAll = openShareAll
|
||||
Vue.prototype.openShareAppMessage = openShareAppMessage
|
||||
Vue.prototype.openShareTimeline = openShareTimeline
|
||||
Vue.prototype.wechatEvevt = wechatEvevt
|
||||
Vue.prototype.ready = ready
|
||||
Vue.prototype.wxShowLocation = wxShowLocation
|
||||
|
||||
// #endif
|
||||
|
||||
// #ifdef APP-PLUS
|
||||
// App平台编译的代码
|
||||
@ -170,4 +96,69 @@ store.commit('updateDevicetype', 'routine')
|
||||
// ...mapState(['$deviceType'])
|
||||
// },
|
||||
|
||||
|
||||
// #ifdef H5
|
||||
// H5编译的代码
|
||||
|
||||
import {
|
||||
wechat,
|
||||
clearAuthStatus,
|
||||
oAuth,
|
||||
auth,
|
||||
toAuth,
|
||||
pay,
|
||||
openAddress,
|
||||
openShareAll,
|
||||
openShareAppMessage,
|
||||
openShareTimeline,
|
||||
wechatEvevt,
|
||||
ready,
|
||||
wxShowLocation,
|
||||
} from '@/libs/wechat'
|
||||
|
||||
import { isWeixin } from '@/utils'
|
||||
const CACHE_KEY = "clear_0.0.1";
|
||||
|
||||
if (!cookie.has(CACHE_KEY)) {
|
||||
cookie.clearAll()
|
||||
cookie.set(CACHE_KEY, 1);
|
||||
}
|
||||
|
||||
var urlSpread = parseQuery()["spread"];
|
||||
if (urlSpread) {
|
||||
cookie.set("spread", urlSpread);
|
||||
}
|
||||
|
||||
// #endif
|
||||
|
||||
|
||||
|
||||
async function init() {
|
||||
|
||||
// #ifdef H5
|
||||
// H5编译的代码
|
||||
// 判断是否是微信浏览器
|
||||
if (isWeixin()) {
|
||||
Vue.prototype.$deviceType = 'weixin'
|
||||
store.commit('updateDevicetype', 'weixin')
|
||||
let wechatInit = await wechat()
|
||||
console.log(wechatInit)
|
||||
if (wechatInit) {
|
||||
await oAuth()
|
||||
app.$mount()
|
||||
}
|
||||
} else {
|
||||
Vue.prototype.$deviceType = 'weixinh5'
|
||||
store.commit('updateDevicetype', 'weixinh5')
|
||||
app.$mount()
|
||||
|
||||
}
|
||||
// #endif
|
||||
|
||||
// #ifndef H5
|
||||
app.$mount()
|
||||
// #endif
|
||||
|
||||
}
|
||||
|
||||
init()
|
||||
|
||||
@ -141,12 +141,12 @@
|
||||
}
|
||||
},
|
||||
"plugins" : {
|
||||
// #ifdef MP-WEIXIN
|
||||
"live-player-plugin" : {
|
||||
// 注意填写该直播组件最新版本号,微信开发者工具调试时可获取最新版本号(复制时请去掉注释)
|
||||
"version" : "1.1.10",
|
||||
// 必须填该直播组件appid,该示例值即为直播组件appid(复制时请去掉注释)
|
||||
"provider" : "wx2b03c6e691cd7370"
|
||||
}
|
||||
// #endif
|
||||
}
|
||||
},
|
||||
"mp-alipay" : {
|
||||
|
||||
@ -424,6 +424,7 @@
|
||||
"navigationBarBackgroundColor": "#F8F8F8",
|
||||
"backgroundColor": "#F8F8F8",
|
||||
"navigationStyle": "default"
|
||||
|
||||
},
|
||||
"tabBar": {
|
||||
"color": "#282828",
|
||||
|
||||
@ -16,16 +16,17 @@
|
||||
// import request from "@//api/request";
|
||||
import {
|
||||
wxappAuth,
|
||||
getUser
|
||||
} from "@/api/user";
|
||||
import dayjs from "dayjs";
|
||||
import store from "@/store";
|
||||
import cookie from "@/utils/store/cookie";
|
||||
import {
|
||||
parseQuery,
|
||||
login,
|
||||
handleQrCode,
|
||||
getCurrentPageUrl,
|
||||
handleUrlParam
|
||||
handleUrlParam,
|
||||
getCurrentPageUrlWithArgs
|
||||
} from "@/utils";
|
||||
|
||||
export default {
|
||||
@ -34,66 +35,55 @@
|
||||
return {};
|
||||
},
|
||||
onShow() {
|
||||
|
||||
console.log('getUser')
|
||||
var url = handleQrCode();
|
||||
if (!url) {
|
||||
url = handleUrlParam(getCurrentPageUrl())
|
||||
url = handleUrlParam(getCurrentPageUrlWithArgs())
|
||||
}
|
||||
// 判断是否是分销
|
||||
if (url) {
|
||||
var spread = cookie.get("spread");
|
||||
let urlSpread = parseInt(url.spread);
|
||||
if (!Number.isNaN(urlSpread) && spread !== urlSpread) {
|
||||
cookie.set("spread", urlSpread || 0);
|
||||
} else if (spread === 0 || typeof spread !== "number") {
|
||||
cookie.set("spread", urlSpread || 0);
|
||||
if (urlSpread) {
|
||||
cookie.set("spread", urlSpread);
|
||||
}
|
||||
if (this.$store.getters.token) {
|
||||
this.toLaunch();
|
||||
return;
|
||||
}
|
||||
// cookie.get("spread");
|
||||
// if (this.$deviceType == "weixin") {
|
||||
// let path = parseQuery().path
|
||||
// console.log(this)
|
||||
// if (path) {
|
||||
// this.$yrouter.push({
|
||||
// path
|
||||
// });
|
||||
// } else {
|
||||
// if (this.$deviceType == "app" || this.$deviceType == "weixinh5") {
|
||||
// this.$yrouter.switchTab({
|
||||
// path: "/pages/home/index"
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
|
||||
// return
|
||||
// }
|
||||
// this.toLaunch();
|
||||
if (this.$deviceType == "app" || this.$deviceType == "h5") {
|
||||
// this.toLaunch();
|
||||
|
||||
this.$yrouter.switchTab({
|
||||
path: "/pages/home/index"
|
||||
});
|
||||
if (this.$store.getters.token) {
|
||||
// 如果token存在,直接进行进页面
|
||||
console.log('登录状态存在,直接进页面')
|
||||
this.toLaunch();
|
||||
return;
|
||||
}
|
||||
console.log('进行登录操作')
|
||||
login().finally(() => {
|
||||
this.$yrouter.switchTab({
|
||||
path: "/pages/home/index"
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions(["changeAuthorization", "setUserInfo"]),
|
||||
...mapActions(["changeAuthorization", "setUserInfo", "getUser"]),
|
||||
toLaunch() {
|
||||
console.log("loading home");
|
||||
this.changeAuthorization(false);
|
||||
let redirect = cookie.get('redirect')
|
||||
if (redirect && redirect.indexOf('/pages') != -1) {
|
||||
this.$yrouter.replace({
|
||||
path: '/pages' + redirect.split('/pages')[1],
|
||||
});
|
||||
cookie.remove('redirect');
|
||||
} else {
|
||||
this.$yrouter.switchTab({
|
||||
path: "/pages/home/index"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
<template>
|
||||
<view class="bargain on">
|
||||
<!-- 在header上加 on 为请求支援 -->
|
||||
<view :class="[bargainPartake != userInfo.uid ? 'wrapper bargain-box on user' : 'wrapper bargain-box user']" v-if="bargainPartake != userInfo.uid">
|
||||
<!-- <view class="people">{{ lookCount }}人查看 丨 {{ shareCount }}人分享 丨 {{ userCount }}人参与</view> -->
|
||||
<!-- 当前登录的用户和url上携带的用户id不一致视为被邀请砍价 -->
|
||||
<view class="wrapper bargain-box on user" v-if="bargainUserInfo && bargainUid != userInfo.uid">
|
||||
<!-- <view class="people">
|
||||
{{ bargainShare.lookCount }}人查看 丨 {{ bargainShare.shareCount }}人分享 丨 {{ bargainShare.userCount }}人参与
|
||||
</view> -->
|
||||
<!-- 帮助砍价、帮砍成功:-->
|
||||
<view class="pictxt acea-row row-center-wrapper ">
|
||||
<div class="bargain-header">
|
||||
@ -19,79 +22,70 @@
|
||||
<view class="wrapper bargain-box time on">
|
||||
<div class="pictxt ">
|
||||
<count-down :isDay="true" :tipText="'倒计时 '" :dayText="' 天 '" :hourText="' 时 '" :minuteText="' 分 '"
|
||||
:secondText="' 秒'" :datatime="datatime"></count-down>
|
||||
:secondText="' 秒'" :datatime="goodsDetail.stopTime"></count-down>
|
||||
</div>
|
||||
</view>
|
||||
<view class="wrapper bargain-box bargain-product">
|
||||
<view class="pictxt acea-row row-between-wrapper" @click="openAlone">
|
||||
<view class="pictrue">
|
||||
<image :src="bargain.image" />
|
||||
<image :src="goodsDetail.image" />
|
||||
<view class="bargain_view">
|
||||
查看商品
|
||||
<view class="iconfont icon-jiantou iconfonts"></view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="text acea-row row-column-around">
|
||||
<view class="line2" v-text="bargain.title"></view>
|
||||
<view class="line2" v-text="goodsDetail.title"></view>
|
||||
<view class="money font-color-red">
|
||||
已砍至: ¥
|
||||
<text class="num" v-text="price"></text>
|
||||
<text class="num" v-text="bargainHelpCount.remainingPrice"></text>
|
||||
</view>
|
||||
<view class="acea-row row-middle">
|
||||
<view class="successNum" v-text="'原价' + bargain.price"></view>
|
||||
<view class="successNum" v-text="'原价' + goodsDetail.price"></view>
|
||||
<view class="successNum" v-text="'已有' + bargainSumCount + '人砍价成功'"></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 砍价进度条 -->
|
||||
<view class="cu-progress acea-row row-middle round margin-top">
|
||||
<view class="acea-row row-middle bg-red" :style="{ width: loading ? pricePercent + '%' : '' }"></view>
|
||||
<view class="acea-row row-middle bg-red" :style="{ width: bargainHelpCount.pricePercent + '%' }"></view>
|
||||
</view>
|
||||
|
||||
<!-- 砍价进度条下的金额 -->
|
||||
<view class="balance acea-row row-between-wrapper">
|
||||
<view v-text="'已砍' + alreadyPrice + '元'"></view>
|
||||
<view v-if="surplusPrice === 0">砍价成功</view>
|
||||
<view v-else v-text="'还剩' + surplusPrice + '元'"></view>
|
||||
<view v-text="'已砍' + bargainHelpCount.alreadyPrice + '元'"></view>
|
||||
<view v-if="bargainHelpCount.remainingPrice === 0">砍价成功</view>
|
||||
<view v-else v-text="'还剩' + bargainHelpCount.remainingPrice + '元'"></view>
|
||||
</view>
|
||||
<!-- 帮助砍价、帮砍成功:-->
|
||||
<!-- <view class="bargainSuccess" v-if="bargainPartake != userInfo.uid && !statusUser && !helpListLoading">
|
||||
<span class="iconfont icon-xiaolian"></span>已成功帮助好友砍价
|
||||
</view> -->
|
||||
|
||||
<!-- 砍价成功:-->
|
||||
<view class="bargainSuccess" v-if="
|
||||
surplusPrice === 0 &&
|
||||
bargainPartake === userInfo.uid &&
|
||||
userBargainStatus === 1 &&
|
||||
!helpListLoading
|
||||
">
|
||||
<!--
|
||||
surplusPrice 砍价剩余金额为0
|
||||
bargainUid 砍价人为发起砍价用户
|
||||
userBargainStatus 砍价状态为
|
||||
-->
|
||||
<view class="bargainSuccess" v-if="pay">
|
||||
<span class="iconfont icon-xiaolian"></span>恭喜您砍价成功,快去支付吧~
|
||||
</view>
|
||||
|
||||
<view v-if="userBargainStatus == 0 && bargainPartake === userInfo.uid" class="bargainBnt" @click="goParticipate">
|
||||
立即参与砍价</view>
|
||||
<view class="bargainBnt" @click="goPoster" v-if="
|
||||
surplusPrice > 0 &&
|
||||
bargainPartake === userInfo.uid &&
|
||||
userBargainStatus === 1 &&
|
||||
!helpListLoading
|
||||
">邀请好友帮砍价</view>
|
||||
<view class="bargainBnt" @click="getBargainHelp" v-else-if="
|
||||
bargainPartake != userInfo.uid &&
|
||||
userBargainStatus == 1 &&
|
||||
statusUser &&
|
||||
!helpListLoading
|
||||
">帮好友砍一刀</view>
|
||||
<view class="bargainBnt" @click="getBargainStart"
|
||||
v-if="bargainPartake != userInfo.uid && !statusUser && !helpListLoading">我也要参与</view>
|
||||
<view class="bargainBnt" @click="goPay" v-if="
|
||||
surplusPrice === 0 &&
|
||||
bargainPartake === userInfo.uid &&
|
||||
userBargainStatus === 1
|
||||
">立即支付</view>
|
||||
<!-- 参与砍价按钮 同一人-->
|
||||
<view v-if="participate" class="bargainBnt" @click="goParticipate">立即发起砍价</view>
|
||||
|
||||
<!-- 邀请好友按钮 -->
|
||||
<view v-if="inviteFriends" class="bargainBnt" @click="goPoster">邀请好友帮砍价</view>
|
||||
|
||||
<!-- 帮砍好友砍按钮 -->
|
||||
<view v-if="helpFriendsBargain" class="bargainBnt" @click="getBargainHelp">帮好友砍一刀</view>
|
||||
|
||||
<!-- 发起砍价按钮 非同一人-->
|
||||
<view v-if="bargain" class="bargainBnt" @click="getBargainStart">我也要砍价</view>
|
||||
|
||||
<!-- 支付按钮 -->
|
||||
<view class="bargainBnt" @click="goPay" v-if="pay">立即支付</view>
|
||||
|
||||
<view class="bargainBnt on" @click="goList">抢更多商品</view>
|
||||
<view class="tip">
|
||||
已有
|
||||
<span class="font-color-red" v-text="helpCount"></span>
|
||||
位好友成功帮您砍价
|
||||
</view>
|
||||
<view class="tip">已有<span class="font-color-red" v-text="bargainHelpCount.count"></span>位好友成功帮您砍价</view>
|
||||
<view class="lock"></view>
|
||||
</view>
|
||||
<view class="bargainGang bargain-box">
|
||||
@ -122,7 +116,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="load font-color-red" v-if="!helpListStatus && !helpListLoading" @click="getBargainHelpList">点击加载更多
|
||||
<view class="load font-color-red" v-if="!helpListStatus " @click="getBargainHelpList">点击加载更多
|
||||
</view>
|
||||
<view class="lock"></view>
|
||||
</view>
|
||||
@ -136,7 +130,7 @@
|
||||
<image src="@/static/images/left.png" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="conter" v-html="bargain.description"></view>
|
||||
<view class="conter" v-html="goodsDetail.description"></view>
|
||||
<view class="lock"></view>
|
||||
</view>
|
||||
<view class="goodsDetails bargain-box">
|
||||
@ -149,21 +143,17 @@
|
||||
<image src="@/static/images/left.png" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="conter" v-html="bargain.rule"></view>
|
||||
<view class="conter" v-html="goodsDetail.rule"></view>
|
||||
</view>
|
||||
<view class="bargainTip" :class="active === true ? 'on' : ''">
|
||||
<!-- <view class="pictrue">
|
||||
<image src="@/static/images/bargainBg.jpg" />
|
||||
<view class="iconfont icon-guanbi" @click="close"></view>
|
||||
</view>-->
|
||||
<view class="cutOff" v-if="bargainPartake === userInfo.uid">
|
||||
<view class="cutOff" v-if="bargainUid === userInfo.uid">
|
||||
您已砍掉
|
||||
<text class="font-color-red" v-text="bargainHelpPrice"></text>元,听说分享次数越多砍价成功的机会越大哦!
|
||||
</view>
|
||||
<view class="cutOff on" v-else>
|
||||
<view class="help font-color-red" v-text="'成功帮砍' + bargainHelpPrice + '元'"></view>,您也可以砍价低价拿哦,快去挑选心仪的商品吧~
|
||||
</view>
|
||||
<view class="tipBnt" @click="goPoster" v-if="bargainPartake === userInfo.uid">邀请好友帮砍价</view>
|
||||
<view class="tipBnt" @click="goPoster" v-if="bargainUid === userInfo.uid">邀请好友帮砍价</view>
|
||||
<view class="tipBnt" @click="getBargainStart" v-else>我也要参与</view>
|
||||
</view>
|
||||
<view class="mask" @touchmove.prevent :hidden="active === false" @click="close"></view>
|
||||
@ -204,118 +194,83 @@
|
||||
props: {},
|
||||
data: function () {
|
||||
return {
|
||||
price: 0,
|
||||
bargainId: 0, //砍价编号
|
||||
bargainPartake: 0, //参与砍价
|
||||
bargain: [], //砍价产品信息
|
||||
partake: null,
|
||||
bargainSumCount: 0, //砍价成功人数
|
||||
activeMsg: "",
|
||||
// ssssss
|
||||
active: false,
|
||||
loading: false,
|
||||
datatime: 0,
|
||||
lookCount: 0, //查看人数
|
||||
shareCount: 0, //分享人数
|
||||
userCount: 0, //参与人数
|
||||
bargainHelpPrice: 0, //砍掉金额
|
||||
bargainHelpList: [],
|
||||
helpListStatus: false, //砍价列表是否获取完成 false 未完成 true 完成
|
||||
helpListLoading: false, //当前接口是否请求完成 false 完成 true 未完成
|
||||
page: 1, //页码
|
||||
limit: 2, //数量
|
||||
helpCount: 0, //砍价帮总人数
|
||||
surplusPrice: 0, //剩余金额
|
||||
alreadyPrice: 0, //已砍掉价格
|
||||
pricePercent: 0, //砍价进度条
|
||||
bargainUserInfo: [], //砍价 开启砍价用户信息
|
||||
userBargainStatus: 2, //砍价状态
|
||||
statusUser: false // 是否帮别人砍,没砍是true,砍了false
|
||||
bargainShare: {}, // 砍价分享的消息
|
||||
bargainHelpCount: {}, // 砍价的信息数据
|
||||
goodsDetail: {}, // 商品的详情
|
||||
bargainUserInfo: [], // 开启砍价用户信息
|
||||
bargainUid: 0, // 参与砍价的用户
|
||||
pay: false, // 支付
|
||||
bargain: false, // 发起砍价
|
||||
participate: false, // 参与砍价
|
||||
inviteFriends: false, // 邀请好友
|
||||
helpFriendsBargain: false, // 帮好友砍
|
||||
bargainSuccess: false, // 帮好友砍价成功
|
||||
mainBargainSuccess: false, // 砍价成功
|
||||
};
|
||||
},
|
||||
computed: mapGetters(["userInfo", "isLogin"]),
|
||||
// watch: {
|
||||
// $yroute: function(n) {
|
||||
// var that = this;
|
||||
// if (n.name === NAME) {
|
||||
// that.mountedStart();
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
mounted: function () {
|
||||
var that = this;
|
||||
that.mountedStart();
|
||||
setTimeout(function () {
|
||||
that.loading = true;
|
||||
}, 500);
|
||||
this.mountedStart();
|
||||
},
|
||||
methods: {
|
||||
onShareAppMessage: function () {
|
||||
return {
|
||||
title: this.storeInfo.title,
|
||||
imageUrl: this.storeInfo.image,
|
||||
path: "pages/activity/DargainDetails/index?id=" + this.storeInfo.id + "&spread=" + uni.getStorageSync(
|
||||
"uid"),
|
||||
success(res) {
|
||||
uni.showToast({
|
||||
title: '分享成功'
|
||||
})
|
||||
},
|
||||
fail(res) {
|
||||
uni.showToast({
|
||||
title: '分享失败',
|
||||
icon: 'none'
|
||||
})
|
||||
// 开始处理砍价逻辑
|
||||
mountedStart: function () {
|
||||
var that = this;
|
||||
let url = handleQrCode();
|
||||
// bargainId 砍价商品id
|
||||
// bargainUid 发起砍价人
|
||||
if (url) {
|
||||
// 通过二维码进来
|
||||
that.bargainId = url.bargainId;
|
||||
that.bargainUid = url.partake;
|
||||
} else {
|
||||
// 正常途径进来
|
||||
that.bargainId = that.$yroute.query.id;
|
||||
that.bargainUid = that.$yroute.query.partake
|
||||
}
|
||||
if (this.bargainUid == 0 || !this.bargainUid) {
|
||||
// url未携带用户uid,填上登录用户uid,跳转
|
||||
that.bargainUid = that.userInfo.uid;
|
||||
}
|
||||
console.log(this)
|
||||
|
||||
// 获取商品详情
|
||||
that.getBargainDetail();
|
||||
// 砍价数据统计
|
||||
that.getBargainShare(0);
|
||||
if (that.bargainUid !== that.userInfo.uid) {
|
||||
that.getBargainStartUser();
|
||||
}
|
||||
},
|
||||
//参与砍价
|
||||
// 发起砍价
|
||||
goParticipate() {
|
||||
if (this.bargainPartake === this.userInfo.uid) this.getBargainStart();
|
||||
else this.getBargainStartUser();
|
||||
//发起人和当前用户为同一人
|
||||
if (this.bargainUid === this.userInfo.uid) {
|
||||
// 变更为当前用户砍价页面
|
||||
this.getBargainStart();
|
||||
} else {
|
||||
// 发起人与当前用户非同一人,变更为发起人的砍价页面
|
||||
this.getBargainStartUser();
|
||||
}
|
||||
this.getBargainHelpCount();
|
||||
},
|
||||
// 查看商品
|
||||
openAlone: function () {
|
||||
this.$yrouter.push({
|
||||
path: "/detail/" + this.bargain.productId
|
||||
});
|
||||
},
|
||||
mountedStart: function () {
|
||||
var that = this;
|
||||
console.log(this)
|
||||
let url = handleQrCode();
|
||||
console.log(url)
|
||||
if (url) {
|
||||
that.bargainId = url.bargainId;
|
||||
that.partake = url.uid;
|
||||
} else {
|
||||
that.bargainId = that.$yroute.query.id;
|
||||
that.partake = parseInt(that.$yroute.query.partake);
|
||||
}
|
||||
if (
|
||||
this.partake === undefined ||
|
||||
this.partake <= 0 ||
|
||||
isNaN(this.partake)
|
||||
) {
|
||||
that.bargainPartake = that.userInfo.uid;
|
||||
// that.$yrouter.push({
|
||||
// path: "/pages/activity/DargainDetails/index",
|
||||
// query: { id: that.bargainId, partake: that.bargainPartake }
|
||||
// });
|
||||
} else {
|
||||
that.bargainPartake = parseInt(this.partake);
|
||||
}
|
||||
|
||||
that.getBargainHelpCountStart();
|
||||
that.getBargainDetail();
|
||||
that.getBargainShare(0);
|
||||
// if (that.bargainPartake !== that.userInfo.uid) that.getBargainStartUser();
|
||||
if (that.bargainPartake === that.userInfo.uid) {
|
||||
// that.getBargainStart();
|
||||
} else {
|
||||
that.getBargainStartUser();
|
||||
}
|
||||
},
|
||||
// 砍价完成,去支付
|
||||
goPay: function () {
|
||||
var data = {};
|
||||
var that = this;
|
||||
@ -341,6 +296,7 @@
|
||||
});
|
||||
});
|
||||
},
|
||||
// 生成海报
|
||||
goPoster: function () {
|
||||
var that = this;
|
||||
that.getBargainShare(that.bargainId);
|
||||
@ -352,6 +308,7 @@
|
||||
}
|
||||
});
|
||||
},
|
||||
// 跳转砍价商品列表
|
||||
goList: function () {
|
||||
this.$yrouter.push({
|
||||
path: "/pages/activity/GoodsBargain/index"
|
||||
@ -365,31 +322,33 @@
|
||||
getBargainShare({
|
||||
bargainId: bargainId
|
||||
}).then(res => {
|
||||
that.lookCount = res.data.lookCount;
|
||||
that.shareCount = res.data.shareCount;
|
||||
that.userCount = res.data.userCount;
|
||||
that.bargainShare = res.data
|
||||
});
|
||||
},
|
||||
// 获取产品详情
|
||||
getBargainDetail: function () {
|
||||
var that = this;
|
||||
uni.showLoading({
|
||||
title: "加载中",
|
||||
mask: true
|
||||
});
|
||||
getBargainDetail(that.bargainId)
|
||||
.then(res => {
|
||||
that.bargain = res.data.bargain;
|
||||
that.bargain.description = that.bargain.description.replace(
|
||||
uni.hideLoading()
|
||||
that.goodsDetail = res.data.bargain;
|
||||
that.goodsDetail.description = that.goodsDetail.description.replace(
|
||||
/\<img/gi,
|
||||
'<img style="max-width:100%;height:auto;"'
|
||||
);
|
||||
that.bargain.rule = that.bargain.rule.replace(
|
||||
that.goodsDetail.rule = that.goodsDetail.rule.replace(
|
||||
/\<img/gi,
|
||||
'<img style="max-width:100%;height:auto;"'
|
||||
);
|
||||
that.datatime = that.bargain.stopTime / 1000;
|
||||
that.goodsDetail.stopTime = that.goodsDetail.stopTime / 1000
|
||||
that.getBargainHelpCount();
|
||||
// that.setOpenShare();
|
||||
that.getBargainHelpList();
|
||||
})
|
||||
.catch(res => {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: "none",
|
||||
@ -397,15 +356,16 @@
|
||||
});
|
||||
});
|
||||
},
|
||||
//开启砍价
|
||||
// 开启砍价-发起人与当前用户非同一人
|
||||
getBargainStart: function () {
|
||||
var that = this;
|
||||
getBargainStart({
|
||||
bargainId: that.bargainId
|
||||
})
|
||||
.then(() => {
|
||||
that.bargainPartake = that.userInfo.uid;
|
||||
that.bargainUid = that.userInfo.uid;
|
||||
that.getBargainHelp();
|
||||
that.getBargainHelpCount();
|
||||
})
|
||||
.catch(res => {
|
||||
uni.showToast({
|
||||
@ -419,8 +379,8 @@
|
||||
getBargainHelp: function () {
|
||||
var that = this;
|
||||
if (
|
||||
that.surplusPrice === 0 &&
|
||||
that.bargainPartake !== that.userInfo.uid
|
||||
this.bargainHelpCount.remainingPrice === 0 &&
|
||||
that.bargainUid !== that.userInfo.uid
|
||||
) {
|
||||
return uni.showToast({
|
||||
title: "好友已经砍价成功",
|
||||
@ -430,15 +390,12 @@
|
||||
}
|
||||
var data = {
|
||||
bargainId: that.bargainId,
|
||||
bargainUserUid: that.bargainPartake
|
||||
bargainUserUid: that.bargainUid
|
||||
};
|
||||
getBargainHelp(data)
|
||||
.then(res => {
|
||||
that.activeMsg = res.data.status;
|
||||
if (
|
||||
res.data.status === "SUCCESSFUL" &&
|
||||
that.bargainPartake !== that.userInfo.uid
|
||||
) {
|
||||
if (res.data.status === "SUCCESSFUL" && that.bargainUid !== that.userInfo.uid) {
|
||||
uni.showToast({
|
||||
title: "您已经砍过了",
|
||||
icon: "none",
|
||||
@ -462,15 +419,12 @@
|
||||
//获取砍掉的金额
|
||||
getBargainHelpPrice: function () {
|
||||
var that = this;
|
||||
that.helpListLoading = true;
|
||||
|
||||
getBargainHelpPrice({
|
||||
bargainId: that.bargainId,
|
||||
bargainUserUid: that.bargainPartake
|
||||
bargainUserUid: that.bargainUid
|
||||
})
|
||||
.then(res => {
|
||||
that.bargainHelpPrice = res.data.price;
|
||||
that.helpListLoading = false;
|
||||
that.getBargainHelpCount();
|
||||
that.getBargainHelpList();
|
||||
switch (that.activeMsg) {
|
||||
@ -489,79 +443,129 @@
|
||||
});
|
||||
});
|
||||
},
|
||||
//砍价帮
|
||||
// 砍价帮助列表
|
||||
getBargainHelpList: function () {
|
||||
var that = this;
|
||||
if (that.helpListLoading === true) return;
|
||||
if (that.helpListStatus === true) return;
|
||||
that.helpListLoading = true;
|
||||
getBargainHelpList({
|
||||
bargainId: that.bargainId,
|
||||
bargainUserUid: that.bargainPartake,
|
||||
bargainUserUid: that.bargainUid,
|
||||
page: that.page,
|
||||
limit: that.limit
|
||||
})
|
||||
.then(res => {
|
||||
that.helpListStatus = res.data.length < that.limit;
|
||||
that.helpListLoading = false;
|
||||
that.page++;
|
||||
if (res.data) {
|
||||
that.bargainHelpList.push.apply(that.bargainHelpList, res.data);
|
||||
}
|
||||
})
|
||||
.catch(res => {
|
||||
.catch(err => {
|
||||
if (!err.msg) {
|
||||
return
|
||||
}
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
title: err.msg || err.response.data.msg || err.response.data.message,
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
});
|
||||
},
|
||||
getBargainHelpCountStart: function () {
|
||||
var that = this;
|
||||
getBargainHelpCount({
|
||||
bargainId: that.bargainId,
|
||||
bargainUserUid: that.bargainPartake
|
||||
})
|
||||
.then(() => {
|
||||
|
||||
})
|
||||
.catch(() => {
|
||||
// this.$yrouter.push({
|
||||
// path: "/pages/activity/DargainDetails/index",
|
||||
// query: {
|
||||
// id: that.bargainId,
|
||||
// partake: that.userInfo.uid
|
||||
// }
|
||||
// });
|
||||
});
|
||||
},
|
||||
// 砍价 砍价帮总人数、剩余金额、进度条、已经砍掉的价格
|
||||
getBargainHelpCount: function () {
|
||||
var that = this;
|
||||
getBargainHelpCount({
|
||||
bargainId: that.bargainId,
|
||||
bargainUserUid: that.bargainPartake
|
||||
bargainId: this.bargainId,
|
||||
bargainUserUid: this.bargainUid
|
||||
})
|
||||
.then(res => {
|
||||
that.userBargainStatus = res.data.status;
|
||||
that.helpCount = res.data.count;
|
||||
that.surplusPrice = res.data.price;
|
||||
that.alreadyPrice = res.data.alreadyPrice;
|
||||
that.pricePercent = res.data.pricePercent;
|
||||
that.price = (that.bargain.price - that.alreadyPrice).toFixed(2);
|
||||
console.log(that);
|
||||
// 剩余砍价金额 = 商品价格 - 已经砍掉的金额
|
||||
let remainingPrice = (this.goodsDetail.price - res.data.alreadyPrice).toFixed(2)
|
||||
this.bargainHelpCount = {
|
||||
...res.data,
|
||||
remainingPrice
|
||||
}
|
||||
this.handleButtonStatus()
|
||||
})
|
||||
.catch(() => {
|
||||
that.bargainPartake = that.userInfo.uid;
|
||||
// that.$yrouter.push({
|
||||
// path: "/pages/activity/DargainDetails/index",
|
||||
// query: { id: that.bargainId, partake: that.userInfo.uid }
|
||||
// });
|
||||
.catch(err => {
|
||||
if (!err.msg) {
|
||||
return
|
||||
}
|
||||
uni.showToast({
|
||||
title: err.msg || err.response.data.msg || err.response.data.message,
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
});
|
||||
},
|
||||
// 判断是否可以支付
|
||||
handleButtonStatus() {
|
||||
// 砍价按钮分为
|
||||
// 1.参与砍价 ==> 发起人与当前用户为同一人 && 未参与
|
||||
if (
|
||||
this.bargainUid === this.userInfo.uid &&
|
||||
this.bargainHelpCount.status == 0
|
||||
) {
|
||||
this.participate = true
|
||||
} else {
|
||||
this.participate = false
|
||||
}
|
||||
|
||||
// 2.邀请好友 ==> 发起人与当前用户同一人 && 已参与未过期 && 剩余金额>0
|
||||
if (
|
||||
this.bargainUid === this.userInfo.uid &&
|
||||
this.bargainHelpCount.status == 1 &&
|
||||
this.bargainHelpCount.remainingPrice > 0
|
||||
) {
|
||||
this.inviteFriends = true
|
||||
} else {
|
||||
this.inviteFriends = false
|
||||
}
|
||||
|
||||
// 3.帮好友砍价 ==> 发起人与当前用户非一人 && 未参与未过期 && 剩余金额>0 && 为砍价
|
||||
if (
|
||||
this.bargainUid != this.userInfo.uid &&
|
||||
this.bargainHelpCount.status == 1 &&
|
||||
// this.bargainHelpCount.userBargainStatus &&
|
||||
this.bargainHelpCount.remainingPrice > 0
|
||||
) {
|
||||
this.helpFriendsBargain = true
|
||||
} else {
|
||||
this.helpFriendsBargain = false
|
||||
}
|
||||
|
||||
// 4.支付 ==> 发起人与当前用户同一人 && 已参与未过期 && 剩余金额<=0
|
||||
if (
|
||||
this.bargainUid === this.userInfo.uid &&
|
||||
this.bargainHelpCount.status == 1 &&
|
||||
this.bargainHelpCount.remainingPrice <= 0
|
||||
) {
|
||||
this.pay = true
|
||||
} else {
|
||||
this.pay = false
|
||||
}
|
||||
|
||||
// 5.砍价人发起新的砍价 ==> 发起人与当前用户非一人 && 未参与
|
||||
if (
|
||||
this.bargainUid != this.userInfo.uid
|
||||
) {
|
||||
this.bargain = true
|
||||
} else {
|
||||
this.bargain = false
|
||||
}
|
||||
|
||||
// 砍价弹窗
|
||||
// 1.发起人砍价成功 ==> 发起人与当前用户同一人 && 已参与未过期
|
||||
// 2.砍价人砍价成功 ==> 发起人与当前用户非一人 && 已参与未过期
|
||||
// 3.已砍价 ==> 已参与 && 砍价状态为 true
|
||||
|
||||
},
|
||||
// 获取开启砍价用户信息
|
||||
// 参与砍价,为同一人发起砍价后
|
||||
getBargainStartUser: function () {
|
||||
var that = this;
|
||||
getBargainStartUser({
|
||||
bargainId: that.bargainId,
|
||||
bargainUserUid: that.bargainPartake
|
||||
bargainUserUid: that.bargainUid
|
||||
})
|
||||
.then(res => {
|
||||
that.bargainUserInfo = res.data;
|
||||
@ -575,9 +579,30 @@
|
||||
});
|
||||
});
|
||||
},
|
||||
// 关闭弹窗
|
||||
close: function () {
|
||||
this.active = false;
|
||||
},
|
||||
// 设置微信分享
|
||||
onShareAppMessage: function () {
|
||||
return {
|
||||
title: this.storeInfo.title,
|
||||
imageUrl: this.storeInfo.image,
|
||||
path: "pages/activity/DargainDetails/index?id=" + this.storeInfo.id + "&spread=" + uni.getStorageSync(
|
||||
"uid"),
|
||||
success(res) {
|
||||
uni.showToast({
|
||||
title: '分享成功'
|
||||
})
|
||||
},
|
||||
fail(res) {
|
||||
uni.showToast({
|
||||
title: '分享失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
onShareAppMessage() {
|
||||
return {
|
||||
|
||||
@ -135,7 +135,10 @@
|
||||
</button>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
|
||||
<view class="item" @click="goHome" >
|
||||
<view class="iconfont icon-shouye-xianxing"></view>
|
||||
<text>首页</text>
|
||||
</view>
|
||||
<view class="item" @click="setCollect" v-if="storeInfo.userCollect">
|
||||
<view class="iconfont icon-shoucang1"></view>
|
||||
<text>收藏</text>
|
||||
@ -217,10 +220,13 @@
|
||||
getCollectDel,
|
||||
getUserInfo,
|
||||
} from "@/api/user";
|
||||
import cookie from "@/utils/store/cookie";
|
||||
import {
|
||||
isWeixin,
|
||||
PosterCanvas,
|
||||
handleQrCode
|
||||
handleQrCode,
|
||||
handleUrlParam,
|
||||
getCurrentPageUrlWithArgs
|
||||
} from "@/utils";
|
||||
import {
|
||||
wechatEvevt
|
||||
@ -303,8 +309,15 @@
|
||||
computed: mapGetters(["isLogin", "location"]),
|
||||
mounted: function () {
|
||||
let url = handleQrCode();
|
||||
if (url && url.productId) {
|
||||
this.id = url.productId;
|
||||
if (!url) {
|
||||
url = handleUrlParam(getCurrentPageUrlWithArgs())
|
||||
}
|
||||
if (url && url.id) {
|
||||
this.id = url.id;
|
||||
let urlSpread = parseInt(url.spread);
|
||||
if (urlSpread) {
|
||||
cookie.set("spread", urlSpread);
|
||||
}
|
||||
} else {
|
||||
this.id = this._route.query.id;
|
||||
}
|
||||
@ -326,7 +339,8 @@
|
||||
return {
|
||||
title: this.storeInfo.storeName,
|
||||
imageUrl: this.storeInfo.image,
|
||||
path: "pages/shop/GoodsCon/index?id=" + this.storeInfo.id + "&spread=" + uni.getStorageSync("uid")+"&pageType=good&codeType=routine",
|
||||
path: "pages/shop/GoodsCon/index?id=" + this.storeInfo.id + "&spread=" + uni.getStorageSync("uid") +
|
||||
"&pageType=good&codeType=routine",
|
||||
success(res) {
|
||||
uni.showToast({
|
||||
title: '分享成功'
|
||||
@ -340,6 +354,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
goHome() {
|
||||
this.$yrouter.switchTab("/pages/home/index");
|
||||
},
|
||||
goShoppingCart() {
|
||||
this.$yrouter.switchTab("/pages/shop/ShoppingCart/index");
|
||||
},
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
<view class="checkbox-wrapper">
|
||||
<checkbox-group @change="switchSelect(cartListValidIndex)">
|
||||
<label class="well-check">
|
||||
<checkbox value :checked="item.checked+''"></checkbox>
|
||||
<checkbox color="#eb3729" value :checked="item.checked"></checkbox>
|
||||
</label>
|
||||
</checkbox-group>
|
||||
</view>
|
||||
@ -113,7 +113,7 @@
|
||||
|
||||
<checkbox-group @change="allChecked">
|
||||
<label class="well-check">
|
||||
<checkbox value="allSelect" :checked="isAllSelect && cartCount > 0"></checkbox>
|
||||
<checkbox color="#eb3729" value="allSelect" :checked="isAllSelect && cartCount > 0"></checkbox>
|
||||
<text class="checkAll">全选 ({{ cartCount }})</text>
|
||||
</label>
|
||||
</checkbox-group>
|
||||
|
||||
@ -62,7 +62,7 @@
|
||||
<!-- <svg class="icon" aria-hidden="true">
|
||||
<use xlink:href="#icon-phone_" />
|
||||
</svg>-->
|
||||
<input type="text" placeholder="输入手机号码" v-model="account" />
|
||||
<input name="account" type="text" placeholder="输入手机号码" v-model="account" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
@ -70,7 +70,7 @@
|
||||
<!-- <svg class="icon" aria-hidden="true">
|
||||
<use xlink:href="#icon-code_1" />
|
||||
</svg>-->
|
||||
<input type="text" placeholder="填写验证码" class="codeIput" v-model="captcha" />
|
||||
<input name="verifyCode" type="text" placeholder="填写验证码" class="codeIput" v-model="captcha" />
|
||||
<button class="code" :disabled="disabled" :class="disabled === true ? 'on' : ''"
|
||||
@click="code">{{ text }}</button>
|
||||
</view>
|
||||
@ -80,7 +80,7 @@
|
||||
<!-- <svg class="icon" aria-hidden="true">
|
||||
<use xlink:href="#icon-code_" />
|
||||
</svg>-->
|
||||
<input type="password" placeholder="填写您的登录密码" v-model="password" />
|
||||
<input name="password" type="password" placeholder="填写您的登录密码" v-model="password" />
|
||||
</view>
|
||||
</view>
|
||||
<!-- #ifndef H5 -->
|
||||
@ -89,7 +89,7 @@
|
||||
<!-- <svg class="icon" aria-hidden="true">
|
||||
<use xlink:href="#icon-phone_" />
|
||||
</svg>-->
|
||||
<input type="text" placeholder="输入邀请码" v-model="inviteCode" />
|
||||
<input name="inviteCode" type="text" placeholder="输入邀请码" v-model="inviteCode" />
|
||||
</view>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
<!-- <svg class="icon" aria-hidden="true">
|
||||
<use xlink:href="#icon-phone_" />
|
||||
</svg> -->
|
||||
<input type="text" placeholder="输入手机号码" />
|
||||
<input name="phone" type="text" placeholder="输入手机号码" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
@ -21,13 +21,9 @@
|
||||
<!-- <svg class="icon" aria-hidden="true">
|
||||
<use xlink:href="#icon-code_1" />
|
||||
</svg> -->
|
||||
<input type="text" placeholder="填写验证码" class="codeIput" />
|
||||
<button
|
||||
class="code"
|
||||
:disabled="disabled"
|
||||
:class="disabled === true ? 'on' : ''"
|
||||
@click="code"
|
||||
>{{ text }}</button>
|
||||
<input name="" type="text" placeholder="填写验证码" class="codeIput" />
|
||||
<button class="verifyCode" :disabled="disabled" :class="disabled === true ? 'on' : ''"
|
||||
@click="code">{{ text }}</button>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
@ -60,7 +56,9 @@ export default {
|
||||
this.sendCode();
|
||||
},
|
||||
goLogin() {
|
||||
this.$yrouter.push({ path: "/pages/user/Login/index" });
|
||||
this.$yrouter.push({
|
||||
path: "/pages/user/Login/index"
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -97,21 +97,21 @@ export default {
|
||||
},
|
||||
getActivity: function() {
|
||||
let that = this;
|
||||
getActivityStatus().then(
|
||||
res => {
|
||||
that.activity.is_bargin = res.data.is_bargin;
|
||||
that.activity.is_pink = res.data.is_pink;
|
||||
that.activity.is_seckill = res.data.is_seckill;
|
||||
},
|
||||
err => {
|
||||
uni.showToast({
|
||||
title:
|
||||
err.msg || err.response.data.msg || err.response.data.message,
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
);
|
||||
// getActivityStatus().then(
|
||||
// res => {
|
||||
// that.activity.is_bargin = res.data.is_bargin;
|
||||
// that.activity.is_pink = res.data.is_pink;
|
||||
// that.activity.is_seckill = res.data.is_seckill;
|
||||
// },
|
||||
// err => {
|
||||
// uni.showToast({
|
||||
// title:
|
||||
// err.msg || err.response.data.msg || err.response.data.message,
|
||||
// icon: "none",
|
||||
// duration: 2000
|
||||
// });
|
||||
// }
|
||||
// );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -178,7 +178,7 @@ export default {
|
||||
res => {
|
||||
that.vipRequire = res.data.list;
|
||||
that.vipComplete = res.data.task;
|
||||
that.taskCount = res.data.reach_count;
|
||||
that.taskCount = res.data.reachCount;
|
||||
},
|
||||
err => {
|
||||
uni.showToast({
|
||||
|
||||
@ -13,22 +13,14 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="nav acea-row row-around">
|
||||
<view
|
||||
class="item"
|
||||
:class="screen.grade == 0 ? 'on' : ''"
|
||||
@click="checkGrade(0)"
|
||||
>一级({{ first||'0' }})</view>
|
||||
<view
|
||||
class="item"
|
||||
:class="screen.grade == 1 ? 'on' : ''"
|
||||
@click="checkGrade(1)"
|
||||
>二级({{ second||'0' }})</view>
|
||||
<view class="item" :class="screen.grade == 0 ? 'on' : ''" @click="checkGrade(0)">一级({{ first||'0' }})</view>
|
||||
<view class="item" :class="screen.grade == 1 ? 'on' : ''" @click="checkGrade(1)">二级({{ second||'0' }})</view>
|
||||
</view>
|
||||
<view class="search acea-row row-between-wrapper">
|
||||
<form @submit.prevent="submitForm">
|
||||
<view class="input">
|
||||
<input placeholder="点击搜索会员名称" v-model="screen.keyword" />
|
||||
<text class="iconfont icon-guanbi"></text>
|
||||
<text class="iconfont icon-guanbi" @click="screen.keyword=''"></text>
|
||||
</view>
|
||||
</form>
|
||||
<view class="iconfont icon-sousuo2"></view>
|
||||
@ -56,11 +48,8 @@
|
||||
</view>
|
||||
</view>
|
||||
<view :class="fixedState === true ? 'sortList' : ''">
|
||||
<view
|
||||
class="item acea-row row-between-wrapper"
|
||||
v-for="(val, spreadListIndex) in spreadList"
|
||||
:key="spreadListIndex"
|
||||
>
|
||||
<view class="item acea-row row-between-wrapper" v-for="(val, spreadListIndex) in spreadList"
|
||||
:key="spreadListIndex">
|
||||
<view class="picTxt acea-row row-between-wrapper">
|
||||
<view class="pictrue">
|
||||
<image :src="val.avatar" />
|
||||
@ -84,7 +73,9 @@
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import { getSpreadUser } from "@/api/user";
|
||||
import {
|
||||
getSpreadUser
|
||||
} from "@/api/user";
|
||||
import Loading from "@/components/Loading";
|
||||
export default {
|
||||
name: "PromoterList",
|
||||
@ -163,8 +154,7 @@ export default {
|
||||
},
|
||||
err => {
|
||||
uni.showToast({
|
||||
title:
|
||||
err.msg || err.response.data.msg || err.response.data.message,
|
||||
title: err.msg || err.response.data.msg || err.response.data.message,
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
|
||||
@ -39,14 +39,7 @@ const vuexStore = new Vuex.Store({
|
||||
console.log('清除数据')
|
||||
state.token = null;
|
||||
state.userInfo = null
|
||||
let spread = cookie.get('spread')
|
||||
let redirect = cookie.get('redirect')
|
||||
let outTime = setTimeout(() => {
|
||||
clearTimeout(outTime)
|
||||
cookie.clearAll()
|
||||
cookie.set('redirect', redirect)
|
||||
cookie.set('spread', spread)
|
||||
}, 100)
|
||||
},
|
||||
backgroundColor(state, color) {
|
||||
state.color = color;
|
||||
@ -97,7 +90,7 @@ const vuexStore = new Vuex.Store({
|
||||
userInfo({ state, commit }, force) {
|
||||
if (state.userInfo !== null && !force) {
|
||||
return Promise.resolve(state.userInfo);
|
||||
} else {
|
||||
}
|
||||
return new Promise(reslove => {
|
||||
getUserInfo().then(res => {
|
||||
commit("updateUserInfo", res.data);
|
||||
@ -110,9 +103,11 @@ const vuexStore = new Vuex.Store({
|
||||
duration: 2000,
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
getUser({ state, commit }) {
|
||||
if (!state.token) {
|
||||
return Promise.reject('未获取到token');
|
||||
}
|
||||
return new Promise(reslove => {
|
||||
getUserInfo().then(res => {
|
||||
console.log(res)
|
||||
@ -163,6 +158,7 @@ const vuexStore = new Vuex.Store({
|
||||
location: state => state.location,
|
||||
storeItems: state => state.storeItems,
|
||||
goName: state => state.goName,
|
||||
$deviceType: state => state.$deviceType,
|
||||
},
|
||||
strict: debug
|
||||
});
|
||||
|
||||
@ -204,7 +204,6 @@ export const authorize = (authorizeStr) => {
|
||||
}
|
||||
|
||||
export const login = () => {
|
||||
console.log(Vue.prototype)
|
||||
return new Promise((resolve, reject) => {
|
||||
if (Vue.prototype.$deviceType == 'weixin') {
|
||||
// 微信授权登录
|
||||
@ -212,47 +211,32 @@ export const login = () => {
|
||||
if (code) {
|
||||
auth(code)
|
||||
.then(() => {
|
||||
// location.replace(
|
||||
// decodeURIComponent(decodeURIComponent(this.$route.params.url))
|
||||
// );
|
||||
location.href = decodeURIComponent(
|
||||
decodeURIComponent(this.$route.params.url)
|
||||
);
|
||||
let redirect = cookie.get('redirect')
|
||||
console.log(redirect)
|
||||
if (redirect) {
|
||||
redirect = redirect.split('/pages')[1]
|
||||
reLaunch({
|
||||
path: '/pages' + redirect,
|
||||
});
|
||||
cookie.remove('redirect');
|
||||
} else {
|
||||
reLaunch({
|
||||
path: '/pages/home/index',
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
reject('当前运行环境为微信浏览器')
|
||||
location.replace("/pages/home/index");
|
||||
reLaunch({
|
||||
path: '/pages/home/index',
|
||||
});
|
||||
});
|
||||
} else {
|
||||
// wechat().then(() => oAuth());
|
||||
}
|
||||
// if (!code) {
|
||||
// toAuth("wxc061dee8806ff712")
|
||||
// } else {
|
||||
// // wechat().then(() => oAuth().then((code) => {
|
||||
// // // const { code } = parseQuery()
|
||||
// // auth(code)
|
||||
// // .then(() => {
|
||||
// // // location.replace(
|
||||
// // // decodeURIComponent(decodeURIComponent(this.$route.params.url))
|
||||
// // // );
|
||||
// // location.href = decodeURIComponent(
|
||||
// // decodeURIComponent(this.$route.params.url)
|
||||
// // );
|
||||
// // })
|
||||
// // .catch(() => {
|
||||
// // reject('当前运行环境为微信浏览器')
|
||||
// // location.replace("/pages/home/index");
|
||||
// // });
|
||||
// // })).catch(error => {
|
||||
// // console.log(error)
|
||||
// // reject('自动登录失败')
|
||||
// // });
|
||||
// }
|
||||
return
|
||||
}
|
||||
if (Vue.prototype.$deviceType == 'weixinh5') {
|
||||
|
||||
console.log('当前运行环境为H5')
|
||||
reject('当前运行环境为H5')
|
||||
return
|
||||
}
|
||||
@ -705,7 +689,8 @@ export const _router = {
|
||||
push,
|
||||
replace,
|
||||
go,
|
||||
back
|
||||
back,
|
||||
reLaunch
|
||||
}
|
||||
|
||||
|
||||
@ -857,14 +842,18 @@ export const handleLoginFailure = () => {
|
||||
console.log('————————')
|
||||
|
||||
store.commit("logout");
|
||||
// 改为授权取消
|
||||
store.commit("updateAuthorization", false);
|
||||
|
||||
let currentPageUrl = getCurrentPageUrl()
|
||||
|
||||
if (store.state.$deviceType == 'weixin') {
|
||||
if (store.getters.isAuthorizationPage){
|
||||
// 如果不是授权页面,
|
||||
if (!store.getters.isAuthorizationPage) {
|
||||
// 标识当前为授权页面
|
||||
store.commit("updateAuthorizationPage", true);
|
||||
toAuth()
|
||||
}
|
||||
return
|
||||
} else {
|
||||
// token 失效
|
||||
// 判断当前是不是已经在登录页面或者授权页,防止二次跳转
|
||||
@ -900,7 +889,9 @@ export const handleLoginFailure = () => {
|
||||
id: qrCode.pinkId,
|
||||
}
|
||||
})
|
||||
if (qrCode.spread) {
|
||||
cookie.set("spread", qrCode.spread || 0);
|
||||
}
|
||||
} else {
|
||||
console.log('————————')
|
||||
console.log('是拼团进来的,但是没有获取到参数')
|
||||
@ -923,7 +914,9 @@ export const handleLoginFailure = () => {
|
||||
partake: qrCode.uid
|
||||
}
|
||||
})
|
||||
if (qrCode.spread) {
|
||||
cookie.set("spread", qrCode.spread || 0);
|
||||
}
|
||||
} else {
|
||||
handleNoParameters()
|
||||
console.log('————————')
|
||||
@ -944,7 +937,9 @@ export const handleLoginFailure = () => {
|
||||
id: qrCode.productId,
|
||||
}
|
||||
})
|
||||
if (qrCode.spread) {
|
||||
cookie.set("spread", qrCode.spread || 0);
|
||||
}
|
||||
} else {
|
||||
handleNoParameters()
|
||||
console.log('————————')
|
||||
|
||||
@ -12,7 +12,7 @@ import Fly from "flyio/dist/npm/wx";
|
||||
import Fly from "flyio/dist/npm/wx";
|
||||
// #endif
|
||||
|
||||
import $store from "../store";
|
||||
import store from "../store";
|
||||
import { handleLoginFailure } from "@/utils";
|
||||
import { VUE_APP_API_URL } from "@/config";
|
||||
import cookie from "@/utils/store/cookie";
|
||||
|
||||
@ -29,7 +29,16 @@ function remove(key) {
|
||||
}
|
||||
|
||||
function clearAll() {
|
||||
uni.clearStorage()
|
||||
const res = uni.getStorageInfoSync();
|
||||
res.keys.map((item) => {
|
||||
if (item == 'redirect' || item == 'spread') {
|
||||
return
|
||||
}
|
||||
remove(item)
|
||||
})
|
||||
console.log(res)
|
||||
// debugger
|
||||
// uni.clearStorageSync()
|
||||
}
|
||||
|
||||
function _has(key) {
|
||||
|
||||
Reference in New Issue
Block a user