hupeng 5 years ago
parent
commit
6584c36afa
  1. 2
      README.md
  2. 2
      assets/css/style.css
  3. 2
      assets/css/style.css.map
  4. 2
      assets/css/style.less
  5. 81
      components/CountDown.vue
  6. 1
      config/index.js
  7. 36
      libs/wechat.js
  8. 99
      main.js
  9. 4
      manifest.json
  10. 1
      pages.json
  11. 56
      pages/Loading/index.vue
  12. 429
      pages/activity/DargainDetails/index.vue
  13. 27
      pages/shop/GoodsCon/index.vue
  14. 4
      pages/shop/ShoppingCart/index.vue
  15. 8
      pages/user/Login/index.vue
  16. 16
      pages/user/Register/index.vue
  17. 30
      pages/user/UserAccount/index.vue
  18. 2
      pages/user/UserVip/index.vue
  19. 28
      pages/user/promotion/PromoterList/index.vue
  20. 14
      store/index.js
  21. 67
      utils/index.js
  22. 2
      utils/request.js
  23. 11
      utils/store/cookie.js

2
README.md

@ -13,7 +13,7 @@
- uni会自动打开微信开发者工具并且打开uni的项目 - uni会自动打开微信开发者工具并且打开uni的项目
## 注意事项 ## 注意事项
- 目前并不支持H5运行,需要运行H5模式的,请自行调整兼容 - uniapp v3.1版本已经兼容h5,另外yshop有自己的H5,uniappv3.1以下版本未对H5端进行处理,如果需要请自行兼容。
- manifest.json 中可以配置uni项目的一些信息 - manifest.json 中可以配置uni项目的一些信息
- 打开manifest.json可配置小程序的 appid - 打开manifest.json可配置小程序的 appid
- 由于需要兼容app,公共样式由 main.js 迁移到了 App.vue,公共样式请在App.vue中进行编辑 - 由于需要兼容app,公共样式由 main.js 迁移到了 App.vue,公共样式请在App.vue中进行编辑

2
assets/css/style.css

File diff suppressed because one or more lines are too long

2
assets/css/style.css.map

File diff suppressed because one or more lines are too long

2
assets/css/style.less

@ -2467,7 +2467,7 @@ page {
right: 0; right: 0;
bottom: 0; bottom: 0;
border-bottom: 1rpx solid #f5f5f5; border-bottom: 1rpx solid #f5f5f5;
z-index: 999; z-index: 99;
height: 1rpx; height: 1rpx;
} }

81
components/CountDown.vue

@ -1,65 +1,67 @@
<template> <template>
<view class="time"> <view class="time">
<text v-if="rtipText">{{ rtipText }}</text> {{ tipText }}
<text class="styleAll" v-if="risDay === true">{{ rday }}</text> <text class="styleAll" v-if="isDay === true">{{ day }}</text>
<text class="timeTxt" v-if="rdayText">{{ rdayText }}</text> <text class="timeTxt">{{ dayText }}</text>
<text class="styleAll">{{ hour }}</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="styleAll">{{ minute }}</text>
<text class="timeTxt" v-if="rminuteText">{{ rminuteText }}</text> <text class="timeTxt">{{ minuteText }}</text>
<text class="styleAll">{{ second }}</text> <text class="styleAll">{{ second }}</text>
<text class="timeTxt" v-if="rsecondText">{{ rsecondText }}</text> <text class="timeTxt">{{ secondText }}</text>
</view> </view>
</template> </template>
<script> <script>
export default { export default {
name: "CountDown", name: "CountDown",
props: [ props: {
// //
'tipText', tipText: {
'dayText', type: String,
'hourText', default: "倒计时"
'minuteText', },
'secondText', dayText: {
'datatime', type: String,
'isDay' 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 () { data: function () {
return { return {
day: "00", day: "00",
hour: "00", hour: "00",
minute: "00", minute: "00",
second: "00", second: "00"
rtipText: "倒计时",
rdayText: "天",
rhourText: "时",
rminuteText: "分",
rsecondText: "秒",
rdatatime: 0,
risDay: true
}; };
}, },
created: function () { 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(); this.show_time();
}, },
mounted: function () {},
methods: { methods: {
show_time: function () { show_time: function () {
let that = this; let that = this;
this.runTime();
setInterval(this.runTime, 1000); function runTime() {
},
runTime() {
let that = this;
// //
let intDiff = that.datatime - Date.parse(new Date()) / 1000; // let intDiff = that.datatime - Date.parse(new Date()) / 1000; //
let day = 0, let day = 0,
@ -94,6 +96,9 @@ export default {
that.second = "00"; that.second = "00";
} }
} }
runTime();
setInterval(runTime, 1000);
}
} }
}; };
</script> </script>

1
config/index.js

@ -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_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'; export const VUE_APP_RESOURCES_URL = 'https://wx.yixiang.co/static';

36
libs/wechat.js

@ -86,9 +86,11 @@ const LOGINTYPE = "loginType";
let instance; let instance;
let wechatObj; let wechatObj;
let appId let appId
let wechatLoading = false
export function wechat() { export function wechat() {
console.log('初始化微信配置') console.log('初始化微信配置')
wechatLoading = false
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (instance) return resolve(instance); if (instance) return resolve(instance);
getWechatConfig() getWechatConfig()
@ -107,12 +109,17 @@ export function wechat() {
}) })
.catch(error => { .catch(error => {
console.log(error) console.log(error)
reject(error) uni.showToast({
title: error,
icon: "none",
duration: 2000
});
reject()
}); });
}) })
.catch(err => { .catch(err => {
console.log(err); console.log(err);
reject(err); reject();
}); });
}); });
} }
@ -122,9 +129,8 @@ export function clearAuthStatus() {
cookie.remove(STATE_KEY); cookie.remove(STATE_KEY);
} }
export function oAuth() { export async function oAuth() {
console.log('处理微信授权') console.log('处理微信授权')
console.log('处理微信授权cookie', cookie.get("spread"))
console.log(store) console.log(store)
console.log(store.state) console.log(store.state)
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -137,6 +143,8 @@ export function oAuth() {
if (!code) { if (!code) {
toAuth(); toAuth();
return return
} else {
auth(code)
} }
resolve() resolve()
}).catch(error => { }).catch(error => {
@ -144,11 +152,12 @@ export function oAuth() {
}) })
} }
export function auth(code) { export async function auth(code) {
console.log('获取微信授权') console.log('获取微信授权')
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let loginType = cookie.get(LOGINTYPE); let loginType = cookie.get(LOGINTYPE);
let spread = cookie.get(spread); let spread = cookie.get('spread');
console.log('微信授权登录前获取spread', spread)
wechatAuth(code, spread, loginType) wechatAuth(code, spread, loginType)
.then(({ data }) => { .then(({ data }) => {
console.log(data) console.log(data)
@ -158,15 +167,22 @@ export function auth(code) {
cookie.set(WX_AUTH, code, expires_time); cookie.set(WX_AUTH, code, expires_time);
cookie.remove(STATE_KEY); cookie.remove(STATE_KEY);
loginType && cookie.remove(LOGINTYPE); loginType && cookie.remove(LOGINTYPE);
console.log('微信公众号授权登录,获取用户信息')
store.dispatch('getUser').finally(() => {
resolve(); resolve();
}) })
})
.catch(reject); .catch(reject);
}).catch(error => { }).catch(error => {
console.log(error) console.log(error)
}) })
} }
export function toAuth() { export async function toAuth() {
if (wechatLoading) {
return
}
wechatLoading = true
wechat().then(wx => { wechat().then(wx => {
location.href = getAuthUrl(appId); location.href = getAuthUrl(appId);
}); });
@ -179,9 +195,9 @@ function getAuthUrl(appId) {
// #ifdef H5 // #ifdef H5
// #endif // #endif
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(`${location.origin}/pages/Loading/index?path=${encodeURIComponent(window.location.href)}`);
// const redirect_uri = encodeURIComponent(`${window.location.origin}${window.location.pathname}`) // const redirect_uri = encodeURIComponent(`${window.location.origin}${window.location.pathname}`)
// const redirect_uri = encodeURIComponent(`${location.origin}`) // const redirect_uri = encodeURIComponent(`${location.origin}`)
cookie.remove(BACK_URL); cookie.remove(BACK_URL);

99
main.js

@ -38,14 +38,6 @@ Vue.prototype.$validator = function (rule) {
return new schema(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 Vue.config.productionTip = false
App.mpType = 'app' App.mpType = 'app'
Vue.prototype.$store = store Vue.prototype.$store = store
@ -82,6 +74,29 @@ Object.defineProperty(Vue.prototype, '$yroute', {
Vue.prototype.$VUE_APP_RESOURCES_URL = VUE_APP_RESOURCES_URL Vue.prototype.$VUE_APP_RESOURCES_URL = VUE_APP_RESOURCES_URL
Vue.prototype.$VUE_APP_API_URL = VUE_APP_API_URL Vue.prototype.$VUE_APP_API_URL = VUE_APP_API_URL
Vue.component('cu-custom', cuCustom); Vue.component('cu-custom', cuCustom);
// #ifdef APP-PLUS
// App平台编译的代码
Vue.prototype.$deviceType = 'app'
store.commit('updateDevicetype', 'app')
Vue.prototype.$platform = uni.getSystemInfoSync().platform
// #endif
// #ifdef MP-WEIXIN
// 微信小程序编译的代码
Vue.prototype.$deviceType = 'routine'
store.commit('updateDevicetype', 'routine')
// #endif
// !!! ps 不建议在 template 中使用 $deviceType 去判断当前环境,很有可能出现 $deviceType 为 undefined 导致判断出错的问题,可以在 script 模块中正常使用
// 建议通过 store 去获取 $deviceType 可以保证 template 中取到的值有效
// import { mapState, mapMutations, mapActions } from 'vuex';
// computed: {
// ...mapState(['$deviceType'])
// },
// #ifdef H5 // #ifdef H5
// H5编译的代码 // H5编译的代码
@ -102,72 +117,48 @@ import {
} from '@/libs/wechat' } from '@/libs/wechat'
import { isWeixin } from '@/utils' import { isWeixin } from '@/utils'
const CACHE_KEY = "clear_0.0.1"; const CACHE_KEY = "clear_0.0.1";
if (!cookie.has(CACHE_KEY)) { if (!cookie.has(CACHE_KEY)) {
cookie.clearAll(); cookie.clearAll()
cookie.set(CACHE_KEY, 1); cookie.set(CACHE_KEY, 1);
} }
var urlSpread = parseQuery()["spread"]; var urlSpread = parseQuery()["spread"];
if (urlSpread) {
if (urlSpread !== undefined) { cookie.set("spread", urlSpread);
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);
}
} }
// #endif
async function init() {
// #ifdef H5
// H5编译的代码
// 判断是否是微信浏览器 // 判断是否是微信浏览器
if (isWeixin()) { if (isWeixin()) {
Vue.prototype.$deviceType = 'weixin' Vue.prototype.$deviceType = 'weixin'
store.commit('updateDevicetype', 'weixin') store.commit('updateDevicetype', 'weixin')
wechat().then(() => oAuth()); let wechatInit = await wechat()
console.log(wechatInit)
if (wechatInit) {
await oAuth()
app.$mount()
}
} else { } else {
Vue.prototype.$deviceType = 'weixinh5' Vue.prototype.$deviceType = 'weixinh5'
store.commit('updateDevicetype', 'weixinh5') store.commit('updateDevicetype', 'weixinh5')
} app.$mount()
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平台编译的代码
Vue.prototype.$deviceType = 'app'
store.commit('updateDevicetype', 'app')
Vue.prototype.$platform = uni.getSystemInfoSync().platform
// #endif // #endif
// #ifdef MP-WEIXIN // #ifndef H5
// 微信小程序编译的代码 app.$mount()
Vue.prototype.$deviceType = 'routine'
store.commit('updateDevicetype', 'routine')
// #endif // #endif
// !!! ps 不建议在 template 中使用 $deviceType 去判断当前环境,很有可能出现 $deviceType 为 undefined 导致判断出错的问题,可以在 script 模块中正常使用 }
// 建议通过 store 去获取 $deviceType 可以保证 template 中取到的值有效
// import { mapState, mapMutations, mapActions } from 'vuex';
// computed: {
// ...mapState(['$deviceType'])
// },
app.$mount() init()

4
manifest.json

@ -141,12 +141,12 @@
} }
}, },
"plugins" : { "plugins" : {
// #ifdef MP-WEIXIN
"live-player-plugin" : { "live-player-plugin" : {
//
"version" : "1.1.10", "version" : "1.1.10",
// appidappid
"provider" : "wx2b03c6e691cd7370" "provider" : "wx2b03c6e691cd7370"
} }
// #endif
} }
}, },
"mp-alipay" : { "mp-alipay" : {

1
pages.json

@ -424,6 +424,7 @@
"navigationBarBackgroundColor": "#F8F8F8", "navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8", "backgroundColor": "#F8F8F8",
"navigationStyle": "default" "navigationStyle": "default"
}, },
"tabBar": { "tabBar": {
"color": "#282828", "color": "#282828",

56
pages/Loading/index.vue

@ -16,16 +16,17 @@
// import request from "@//api/request"; // import request from "@//api/request";
import { import {
wxappAuth, wxappAuth,
getUser
} from "@/api/user"; } from "@/api/user";
import dayjs from "dayjs"; import dayjs from "dayjs";
import store from "@/store";
import cookie from "@/utils/store/cookie"; import cookie from "@/utils/store/cookie";
import { import {
parseQuery, parseQuery,
login, login,
handleQrCode, handleQrCode,
getCurrentPageUrl, getCurrentPageUrl,
handleUrlParam handleUrlParam,
getCurrentPageUrlWithArgs
} from "@/utils"; } from "@/utils";
export default { export default {
@ -34,66 +35,55 @@
return {}; return {};
}, },
onShow() { onShow() {
console.log('getUser')
var url = handleQrCode(); var url = handleQrCode();
if (!url) { if (!url) {
url = handleUrlParam(getCurrentPageUrl()) url = handleUrlParam(getCurrentPageUrlWithArgs())
} }
// //
if (url) { if (url) {
var spread = cookie.get("spread");
let urlSpread = parseInt(url.spread); let urlSpread = parseInt(url.spread);
if (!Number.isNaN(urlSpread) && spread !== urlSpread) { if (urlSpread) {
cookie.set("spread", urlSpread || 0); cookie.set("spread", urlSpread);
} else if (spread === 0 || typeof spread !== "number") {
cookie.set("spread", urlSpread || 0);
} }
if (this.$store.getters.token) {
this.toLaunch();
return;
} }
// cookie.get("spread"); // if (this.$deviceType == "app" || this.$deviceType == "weixinh5") {
// if (this.$deviceType == "weixin") {
// let path = parseQuery().path
// console.log(this)
// if (path) {
// this.$yrouter.push({
// path
// });
// } else {
// this.$yrouter.switchTab({ // this.$yrouter.switchTab({
// path: "/pages/home/index" // path: "/pages/home/index"
// }); // });
// return;
// } // }
if (this.$store.getters.token) {
// return // token
// } console.log('登录状态存在,直接进页面')
// this.toLaunch(); this.toLaunch();
if (this.$deviceType == "app" || this.$deviceType == "h5") {
// this.toLaunch();
this.$yrouter.switchTab({
path: "/pages/home/index"
});
return; return;
} }
console.log('进行登录操作')
login().finally(() => { login().finally(() => {
this.$yrouter.switchTab({ this.$yrouter.switchTab({
path: "/pages/home/index" path: "/pages/home/index"
}); });
}); });
}
}, },
methods: { methods: {
...mapActions(["changeAuthorization", "setUserInfo"]), ...mapActions(["changeAuthorization", "setUserInfo", "getUser"]),
toLaunch() { toLaunch() {
console.log("loading home"); console.log("loading home");
this.changeAuthorization(false); 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({ this.$yrouter.switchTab({
path: "/pages/home/index" path: "/pages/home/index"
}); });
} }
} }
}
}; };
</script> </script>

429
pages/activity/DargainDetails/index.vue

@ -1,8 +1,11 @@
<template> <template>
<view class="bargain on"> <view class="bargain on">
<!-- 在header上加 on 为请求支援 --> <!-- 在header上加 on 为请求支援 -->
<view :class="[bargainPartake != userInfo.uid ? 'wrapper bargain-box on user' : 'wrapper bargain-box user']" v-if="bargainPartake != userInfo.uid"> <!-- 当前登录的用户和url上携带的用户id不一致视为被邀请砍价 -->
<!-- <view class="people">{{ lookCount }}人查看 {{ shareCount }}人分享 {{ userCount }}人参与</view> --> <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 "> <view class="pictxt acea-row row-center-wrapper ">
<div class="bargain-header"> <div class="bargain-header">
@ -19,79 +22,70 @@
<view class="wrapper bargain-box time on"> <view class="wrapper bargain-box time on">
<div class="pictxt "> <div class="pictxt ">
<count-down :isDay="true" :tipText="'倒计时 '" :dayText="' 天 '" :hourText="' 时 '" :minuteText="' 分 '" <count-down :isDay="true" :tipText="'倒计时 '" :dayText="' 天 '" :hourText="' 时 '" :minuteText="' 分 '"
:secondText="' 秒'" :datatime="datatime"></count-down> :secondText="' 秒'" :datatime="goodsDetail.stopTime"></count-down>
</div> </div>
</view> </view>
<view class="wrapper bargain-box bargain-product"> <view class="wrapper bargain-box bargain-product">
<view class="pictxt acea-row row-between-wrapper" @click="openAlone"> <view class="pictxt acea-row row-between-wrapper" @click="openAlone">
<view class="pictrue"> <view class="pictrue">
<image :src="bargain.image" /> <image :src="goodsDetail.image" />
<view class="bargain_view"> <view class="bargain_view">
查看商品 查看商品
<view class="iconfont icon-jiantou iconfonts"></view> <view class="iconfont icon-jiantou iconfonts"></view>
</view> </view>
</view> </view>
<view class="text acea-row row-column-around"> <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"> <view class="money font-color-red">
已砍至: 已砍至:
<text class="num" v-text="price"></text> <text class="num" v-text="bargainHelpCount.remainingPrice"></text>
</view> </view>
<view class="acea-row row-middle"> <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 class="successNum" v-text="'已有' + bargainSumCount + '人砍价成功'"></view>
</view> </view>
</view> </view>
</view> </view>
<!-- 砍价进度条 -->
<view class="cu-progress acea-row row-middle round margin-top"> <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>
<!-- 砍价进度条下的金额 -->
<view class="balance acea-row row-between-wrapper"> <view class="balance acea-row row-between-wrapper">
<view v-text="'已砍' + alreadyPrice + '元'"></view> <view v-text="'已砍' + bargainHelpCount.alreadyPrice + '元'"></view>
<view v-if="surplusPrice === 0">砍价成功</view> <view v-if="bargainHelpCount.remainingPrice === 0">砍价成功</view>
<view v-else v-text="'还剩' + surplusPrice + '元'"></view> <view v-else v-text="'还剩' + bargainHelpCount.remainingPrice + '元'"></view>
</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 && surplusPrice 砍价剩余金额为0
bargainPartake === userInfo.uid && bargainUid 砍价人为发起砍价用户
userBargainStatus === 1 && userBargainStatus 砍价状态为
!helpListLoading -->
"> <view class="bargainSuccess" v-if="pay">
<span class="iconfont icon-xiaolian"></span>恭喜您砍价成功快去支付吧~ <span class="iconfont icon-xiaolian"></span>恭喜您砍价成功快去支付吧~
</view> </view>
<view v-if="userBargainStatus == 0 && bargainPartake === userInfo.uid" class="bargainBnt" @click="goParticipate"> <!-- 参与砍价按钮 同一人-->
立即参与砍价</view> <view v-if="participate" class="bargainBnt" @click="goParticipate">立即发起砍价</view>
<view class="bargainBnt" @click="goPoster" v-if="
surplusPrice > 0 && <!-- 邀请好友按钮 -->
bargainPartake === userInfo.uid && <view v-if="inviteFriends" class="bargainBnt" @click="goPoster">邀请好友帮砍价</view>
userBargainStatus === 1 &&
!helpListLoading <!-- 帮砍好友砍按钮 -->
">邀请好友帮砍价</view> <view v-if="helpFriendsBargain" class="bargainBnt" @click="getBargainHelp">帮好友砍一刀</view>
<view class="bargainBnt" @click="getBargainHelp" v-else-if="
bargainPartake != userInfo.uid && <!-- 发起砍价按钮 非同一人-->
userBargainStatus == 1 && <view v-if="bargain" class="bargainBnt" @click="getBargainStart">我也要砍价</view>
statusUser &&
!helpListLoading <!-- 支付按钮 -->
">帮好友砍一刀</view> <view class="bargainBnt" @click="goPay" v-if="pay">立即支付</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 class="bargainBnt on" @click="goList">抢更多商品</view> <view class="bargainBnt on" @click="goList">抢更多商品</view>
<view class="tip"> <view class="tip">已有<span class="font-color-red" v-text="bargainHelpCount.count"></span>位好友成功帮您砍价</view>
已有
<span class="font-color-red" v-text="helpCount"></span>
位好友成功帮您砍价
</view>
<view class="lock"></view> <view class="lock"></view>
</view> </view>
<view class="bargainGang bargain-box"> <view class="bargainGang bargain-box">
@ -122,7 +116,7 @@
</view> </view>
</view> </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>
<view class="lock"></view> <view class="lock"></view>
</view> </view>
@ -136,7 +130,7 @@
<image src="@/static/images/left.png" /> <image src="@/static/images/left.png" />
</view> </view>
</view> </view>
<view class="conter" v-html="bargain.description"></view> <view class="conter" v-html="goodsDetail.description"></view>
<view class="lock"></view> <view class="lock"></view>
</view> </view>
<view class="goodsDetails bargain-box"> <view class="goodsDetails bargain-box">
@ -149,21 +143,17 @@
<image src="@/static/images/left.png" /> <image src="@/static/images/left.png" />
</view> </view>
</view> </view>
<view class="conter" v-html="bargain.rule"></view> <view class="conter" v-html="goodsDetail.rule"></view>
</view> </view>
<view class="bargainTip" :class="active === true ? 'on' : ''"> <view class="bargainTip" :class="active === true ? 'on' : ''">
<!-- <view class="pictrue"> <view class="cutOff" v-if="bargainUid === userInfo.uid">
<image src="@/static/images/bargainBg.jpg" />
<view class="iconfont icon-guanbi" @click="close"></view>
</view>-->
<view class="cutOff" v-if="bargainPartake === userInfo.uid">
您已砍掉 您已砍掉
<text class="font-color-red" v-text="bargainHelpPrice"></text>听说分享次数越多砍价成功的机会越大哦 <text class="font-color-red" v-text="bargainHelpPrice"></text>听说分享次数越多砍价成功的机会越大哦
</view> </view>
<view class="cutOff on" v-else> <view class="cutOff on" v-else>
<view class="help font-color-red" v-text="'成功帮砍' + bargainHelpPrice + '元'"></view>您也可以砍价低价拿哦快去挑选心仪的商品吧~ <view class="help font-color-red" v-text="'成功帮砍' + bargainHelpPrice + '元'"></view>您也可以砍价低价拿哦快去挑选心仪的商品吧~
</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 class="tipBnt" @click="getBargainStart" v-else>我也要参与</view>
</view> </view>
<view class="mask" @touchmove.prevent :hidden="active === false" @click="close"></view> <view class="mask" @touchmove.prevent :hidden="active === false" @click="close"></view>
@ -204,118 +194,83 @@
props: {}, props: {},
data: function () { data: function () {
return { return {
price: 0,
bargainId: 0, // bargainId: 0, //
bargainPartake: 0, //
bargain: [], //
partake: null,
bargainSumCount: 0, // bargainSumCount: 0, //
activeMsg: "", activeMsg: "",
// ssssss
active: false, active: false,
loading: false,
datatime: 0,
lookCount: 0, //
shareCount: 0, //
userCount: 0, //
bargainHelpPrice: 0, // bargainHelpPrice: 0, //
bargainHelpList: [], bargainHelpList: [],
helpListStatus: false, // false true helpListStatus: false, // false true
helpListLoading: false, // false true
page: 1, // page: 1, //
limit: 2, // limit: 2, //
helpCount: 0, //
surplusPrice: 0, //
alreadyPrice: 0, //
pricePercent: 0, // pricePercent: 0, //
bargainUserInfo: [], // bargainShare: {}, //
userBargainStatus: 2, // bargainHelpCount: {}, //
statusUser: false // ,truefalse goodsDetail: {}, //
bargainUserInfo: [], //
bargainUid: 0, //
pay: false, //
bargain: false, //
participate: false, //
inviteFriends: false, //
helpFriendsBargain: false, //
bargainSuccess: false, //
mainBargainSuccess: false, //
}; };
}, },
computed: mapGetters(["userInfo", "isLogin"]), computed: mapGetters(["userInfo", "isLogin"]),
// watch: {
// $yroute: function(n) {
// var that = this;
// if (n.name === NAME) {
// that.mountedStart();
// }
// }
// },
mounted: function () { mounted: function () {
var that = this; this.mountedStart();
that.mountedStart();
setTimeout(function () {
that.loading = true;
}, 500);
}, },
methods: { 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'
})
}
}
},
//
goParticipate() {
if (this.bargainPartake === this.userInfo.uid) this.getBargainStart();
else this.getBargainStartUser();
this.getBargainHelpCount();
},
openAlone: function () {
this.$yrouter.push({
path: "/detail/" + this.bargain.productId
});
},
mountedStart: function () { mountedStart: function () {
var that = this; var that = this;
console.log(this)
let url = handleQrCode(); let url = handleQrCode();
console.log(url) // bargainId id
// bargainUid
if (url) { if (url) {
//
that.bargainId = url.bargainId; that.bargainId = url.bargainId;
that.partake = url.uid; that.bargainUid = url.partake;
} else { } else {
//
that.bargainId = that.$yroute.query.id; that.bargainId = that.$yroute.query.id;
that.partake = parseInt(that.$yroute.query.partake); that.bargainUid = that.$yroute.query.partake
} }
if ( if (this.bargainUid == 0 || !this.bargainUid) {
this.partake === undefined || // urluiduid
this.partake <= 0 || that.bargainUid = that.userInfo.uid;
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);
} }
console.log(this)
that.getBargainHelpCountStart(); //
that.getBargainDetail(); that.getBargainDetail();
//
that.getBargainShare(0); that.getBargainShare(0);
// if (that.bargainPartake !== that.userInfo.uid) that.getBargainStartUser(); if (that.bargainUid !== that.userInfo.uid) {
if (that.bargainPartake === that.userInfo.uid) {
// that.getBargainStart();
} else {
that.getBargainStartUser(); that.getBargainStartUser();
} }
}, },
//
goParticipate() {
//
if (this.bargainUid === this.userInfo.uid) {
//
this.getBargainStart();
} else {
//
this.getBargainStartUser();
}
this.getBargainHelpCount();
},
//
openAlone: function () {
this.$yrouter.push({
path: "/detail/" + this.bargain.productId
});
},
//
goPay: function () { goPay: function () {
var data = {}; var data = {};
var that = this; var that = this;
@ -341,6 +296,7 @@
}); });
}); });
}, },
//
goPoster: function () { goPoster: function () {
var that = this; var that = this;
that.getBargainShare(that.bargainId); that.getBargainShare(that.bargainId);
@ -352,6 +308,7 @@
} }
}); });
}, },
//
goList: function () { goList: function () {
this.$yrouter.push({ this.$yrouter.push({
path: "/pages/activity/GoodsBargain/index" path: "/pages/activity/GoodsBargain/index"
@ -365,31 +322,33 @@
getBargainShare({ getBargainShare({
bargainId: bargainId bargainId: bargainId
}).then(res => { }).then(res => {
that.lookCount = res.data.lookCount; that.bargainShare = res.data
that.shareCount = res.data.shareCount;
that.userCount = res.data.userCount;
}); });
}, },
// //
getBargainDetail: function () { getBargainDetail: function () {
var that = this; var that = this;
uni.showLoading({
title: "加载中",
mask: true
});
getBargainDetail(that.bargainId) getBargainDetail(that.bargainId)
.then(res => { .then(res => {
that.bargain = res.data.bargain; uni.hideLoading()
that.bargain.description = that.bargain.description.replace( that.goodsDetail = res.data.bargain;
that.goodsDetail.description = that.goodsDetail.description.replace(
/\<img/gi, /\<img/gi,
'<img style="max-width:100%;height:auto;"' '<img style="max-width:100%;height:auto;"'
); );
that.bargain.rule = that.bargain.rule.replace( that.goodsDetail.rule = that.goodsDetail.rule.replace(
/\<img/gi, /\<img/gi,
'<img style="max-width:100%;height:auto;"' '<img style="max-width:100%;height:auto;"'
); );
that.datatime = that.bargain.stopTime / 1000; that.goodsDetail.stopTime = that.goodsDetail.stopTime / 1000
that.getBargainHelpCount(); that.getBargainHelpCount();
// that.setOpenShare();
that.getBargainHelpList();
}) })
.catch(res => { .catch(res => {
uni.hideLoading()
uni.showToast({ uni.showToast({
title: res.msg, title: res.msg,
icon: "none", icon: "none",
@ -397,15 +356,16 @@
}); });
}); });
}, },
// // -
getBargainStart: function () { getBargainStart: function () {
var that = this; var that = this;
getBargainStart({ getBargainStart({
bargainId: that.bargainId bargainId: that.bargainId
}) })
.then(() => { .then(() => {
that.bargainPartake = that.userInfo.uid; that.bargainUid = that.userInfo.uid;
that.getBargainHelp(); that.getBargainHelp();
that.getBargainHelpCount();
}) })
.catch(res => { .catch(res => {
uni.showToast({ uni.showToast({
@ -419,8 +379,8 @@
getBargainHelp: function () { getBargainHelp: function () {
var that = this; var that = this;
if ( if (
that.surplusPrice === 0 && this.bargainHelpCount.remainingPrice === 0 &&
that.bargainPartake !== that.userInfo.uid that.bargainUid !== that.userInfo.uid
) { ) {
return uni.showToast({ return uni.showToast({
title: "好友已经砍价成功", title: "好友已经砍价成功",
@ -430,15 +390,12 @@
} }
var data = { var data = {
bargainId: that.bargainId, bargainId: that.bargainId,
bargainUserUid: that.bargainPartake bargainUserUid: that.bargainUid
}; };
getBargainHelp(data) getBargainHelp(data)
.then(res => { .then(res => {
that.activeMsg = res.data.status; that.activeMsg = res.data.status;
if ( if (res.data.status === "SUCCESSFUL" && that.bargainUid !== that.userInfo.uid) {
res.data.status === "SUCCESSFUL" &&
that.bargainPartake !== that.userInfo.uid
) {
uni.showToast({ uni.showToast({
title: "您已经砍过了", title: "您已经砍过了",
icon: "none", icon: "none",
@ -462,15 +419,12 @@
// //
getBargainHelpPrice: function () { getBargainHelpPrice: function () {
var that = this; var that = this;
that.helpListLoading = true;
getBargainHelpPrice({ getBargainHelpPrice({
bargainId: that.bargainId, bargainId: that.bargainId,
bargainUserUid: that.bargainPartake bargainUserUid: that.bargainUid
}) })
.then(res => { .then(res => {
that.bargainHelpPrice = res.data.price; that.bargainHelpPrice = res.data.price;
that.helpListLoading = false;
that.getBargainHelpCount(); that.getBargainHelpCount();
that.getBargainHelpList(); that.getBargainHelpList();
switch (that.activeMsg) { switch (that.activeMsg) {
@ -489,79 +443,129 @@
}); });
}); });
}, },
// //
getBargainHelpList: function () { getBargainHelpList: function () {
var that = this; var that = this;
if (that.helpListLoading === true) return;
if (that.helpListStatus === true) return; if (that.helpListStatus === true) return;
that.helpListLoading = true;
getBargainHelpList({ getBargainHelpList({
bargainId: that.bargainId, bargainId: that.bargainId,
bargainUserUid: that.bargainPartake, bargainUserUid: that.bargainUid,
page: that.page, page: that.page,
limit: that.limit limit: that.limit
}) })
.then(res => { .then(res => {
that.helpListStatus = res.data.length < that.limit; that.helpListStatus = res.data.length < that.limit;
that.helpListLoading = false;
that.page++; that.page++;
if (res.data) {
that.bargainHelpList.push.apply(that.bargainHelpList, res.data); that.bargainHelpList.push.apply(that.bargainHelpList, res.data);
}
}) })
.catch(res => { .catch(err => {
if (!err.msg) {
return
}
uni.showToast({ uni.showToast({
title: res.msg, title: err.msg || err.response.data.msg || err.response.data.message,
icon: "none", icon: "none",
duration: 2000 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 () { getBargainHelpCount: function () {
var that = this;
getBargainHelpCount({ getBargainHelpCount({
bargainId: that.bargainId, bargainId: this.bargainId,
bargainUserUid: that.bargainPartake bargainUserUid: this.bargainUid
}) })
.then(res => { .then(res => {
that.userBargainStatus = res.data.status; // = -
that.helpCount = res.data.count; let remainingPrice = (this.goodsDetail.price - res.data.alreadyPrice).toFixed(2)
that.surplusPrice = res.data.price; this.bargainHelpCount = {
that.alreadyPrice = res.data.alreadyPrice; ...res.data,
that.pricePercent = res.data.pricePercent; remainingPrice
that.price = (that.bargain.price - that.alreadyPrice).toFixed(2); }
console.log(that); this.handleButtonStatus()
}) })
.catch(() => { .catch(err => {
that.bargainPartake = that.userInfo.uid; if (!err.msg) {
// that.$yrouter.push({ return
// path: "/pages/activity/DargainDetails/index", }
// query: { id: that.bargainId, partake: that.userInfo.uid } 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 () { getBargainStartUser: function () {
var that = this; var that = this;
getBargainStartUser({ getBargainStartUser({
bargainId: that.bargainId, bargainId: that.bargainId,
bargainUserUid: that.bargainPartake bargainUserUid: that.bargainUid
}) })
.then(res => { .then(res => {
that.bargainUserInfo = res.data; that.bargainUserInfo = res.data;
@ -575,9 +579,30 @@
}); });
}); });
}, },
//
close: function () { close: function () {
this.active = false; 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() { onShareAppMessage() {
return { return {

27
pages/shop/GoodsCon/index.vue

@ -135,7 +135,10 @@
</button> </button>
</view> </view>
<!-- #endif --> <!-- #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="item" @click="setCollect" v-if="storeInfo.userCollect">
<view class="iconfont icon-shoucang1"></view> <view class="iconfont icon-shoucang1"></view>
<text>收藏</text> <text>收藏</text>
@ -217,10 +220,13 @@
getCollectDel, getCollectDel,
getUserInfo, getUserInfo,
} from "@/api/user"; } from "@/api/user";
import cookie from "@/utils/store/cookie";
import { import {
isWeixin, isWeixin,
PosterCanvas, PosterCanvas,
handleQrCode handleQrCode,
handleUrlParam,
getCurrentPageUrlWithArgs
} from "@/utils"; } from "@/utils";
import { import {
wechatEvevt wechatEvevt
@ -303,8 +309,15 @@
computed: mapGetters(["isLogin", "location"]), computed: mapGetters(["isLogin", "location"]),
mounted: function () { mounted: function () {
let url = handleQrCode(); let url = handleQrCode();
if (url && url.productId) { if (!url) {
this.id = url.productId; url = handleUrlParam(getCurrentPageUrlWithArgs())
}
if (url && url.id) {
this.id = url.id;
let urlSpread = parseInt(url.spread);
if (urlSpread) {
cookie.set("spread", urlSpread);
}
} else { } else {
this.id = this._route.query.id; this.id = this._route.query.id;
} }
@ -326,7 +339,8 @@
return { return {
title: this.storeInfo.storeName, title: this.storeInfo.storeName,
imageUrl: this.storeInfo.image, 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) { success(res) {
uni.showToast({ uni.showToast({
title: '分享成功' title: '分享成功'
@ -340,6 +354,9 @@
} }
} }
}, },
goHome() {
this.$yrouter.switchTab("/pages/home/index");
},
goShoppingCart() { goShoppingCart() {
this.$yrouter.switchTab("/pages/shop/ShoppingCart/index"); this.$yrouter.switchTab("/pages/shop/ShoppingCart/index");
}, },

4
pages/shop/ShoppingCart/index.vue

@ -28,7 +28,7 @@
<view class="checkbox-wrapper"> <view class="checkbox-wrapper">
<checkbox-group @change="switchSelect(cartListValidIndex)"> <checkbox-group @change="switchSelect(cartListValidIndex)">
<label class="well-check"> <label class="well-check">
<checkbox value :checked="item.checked+''"></checkbox> <checkbox color="#eb3729" value :checked="item.checked"></checkbox>
</label> </label>
</checkbox-group> </checkbox-group>
</view> </view>
@ -113,7 +113,7 @@
<checkbox-group @change="allChecked"> <checkbox-group @change="allChecked">
<label class="well-check"> <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> <text class="checkAll">全选 ({{ cartCount }})</text>
</label> </label>
</checkbox-group> </checkbox-group>

8
pages/user/Login/index.vue

@ -62,7 +62,7 @@
<!-- <svg class="icon" aria-hidden="true"> <!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-phone_" /> <use xlink:href="#icon-phone_" />
</svg>--> </svg>-->
<input type="text" placeholder="输入手机号码" v-model="account" /> <input name="account" type="text" placeholder="输入手机号码" v-model="account" />
</view> </view>
</view> </view>
<view class="item"> <view class="item">
@ -70,7 +70,7 @@
<!-- <svg class="icon" aria-hidden="true"> <!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-code_1" /> <use xlink:href="#icon-code_1" />
</svg>--> </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' : ''" <button class="code" :disabled="disabled" :class="disabled === true ? 'on' : ''"
@click="code">{{ text }}</button> @click="code">{{ text }}</button>
</view> </view>
@ -80,7 +80,7 @@
<!-- <svg class="icon" aria-hidden="true"> <!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-code_" /> <use xlink:href="#icon-code_" />
</svg>--> </svg>-->
<input type="password" placeholder="填写您的登录密码" v-model="password" /> <input name="password" type="password" placeholder="填写您的登录密码" v-model="password" />
</view> </view>
</view> </view>
<!-- #ifndef H5 --> <!-- #ifndef H5 -->
@ -89,7 +89,7 @@
<!-- <svg class="icon" aria-hidden="true"> <!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-phone_" /> <use xlink:href="#icon-phone_" />
</svg>--> </svg>-->
<input type="text" placeholder="输入邀请码" v-model="inviteCode" /> <input name="inviteCode" type="text" placeholder="输入邀请码" v-model="inviteCode" />
</view> </view>
</view> </view>
<!-- #endif --> <!-- #endif -->

16
pages/user/Register/index.vue

@ -13,7 +13,7 @@
<!-- <svg class="icon" aria-hidden="true"> <!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-phone_" /> <use xlink:href="#icon-phone_" />
</svg> --> </svg> -->
<input type="text" placeholder="输入手机号码" /> <input name="phone" type="text" placeholder="输入手机号码" />
</view> </view>
</view> </view>
<view class="item"> <view class="item">
@ -21,13 +21,9 @@
<!-- <svg class="icon" aria-hidden="true"> <!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-code_1" /> <use xlink:href="#icon-code_1" />
</svg> --> </svg> -->
<input type="text" placeholder="填写验证码" class="codeIput" /> <input name="" type="text" placeholder="填写验证码" class="codeIput" />
<button <button class="verifyCode" :disabled="disabled" :class="disabled === true ? 'on' : ''"
class="code" @click="code">{{ text }}</button>
:disabled="disabled"
:class="disabled === true ? 'on' : ''"
@click="code"
>{{ text }}</button>
</view> </view>
</view> </view>
<view class="item"> <view class="item">
@ -60,7 +56,9 @@ export default {
this.sendCode(); this.sendCode();
}, },
goLogin() { goLogin() {
this.$yrouter.push({ path: "/pages/user/Login/index" }); this.$yrouter.push({
path: "/pages/user/Login/index"
});
} }
} }
}; };

30
pages/user/UserAccount/index.vue

@ -97,21 +97,21 @@ export default {
}, },
getActivity: function() { getActivity: function() {
let that = this; let that = this;
getActivityStatus().then( // getActivityStatus().then(
res => { // res => {
that.activity.is_bargin = res.data.is_bargin; // that.activity.is_bargin = res.data.is_bargin;
that.activity.is_pink = res.data.is_pink; // that.activity.is_pink = res.data.is_pink;
that.activity.is_seckill = res.data.is_seckill; // that.activity.is_seckill = res.data.is_seckill;
}, // },
err => { // err => {
uni.showToast({ // uni.showToast({
title: // title:
err.msg || err.response.data.msg || err.response.data.message, // err.msg || err.response.data.msg || err.response.data.message,
icon: "none", // icon: "none",
duration: 2000 // duration: 2000
}); // });
} // }
); // );
} }
} }
}; };

2
pages/user/UserVip/index.vue

@ -178,7 +178,7 @@ export default {
res => { res => {
that.vipRequire = res.data.list; that.vipRequire = res.data.list;
that.vipComplete = res.data.task; that.vipComplete = res.data.task;
that.taskCount = res.data.reach_count; that.taskCount = res.data.reachCount;
}, },
err => { err => {
uni.showToast({ uni.showToast({

28
pages/user/promotion/PromoterList/index.vue

@ -13,22 +13,14 @@
</view> </view>
</view> </view>
<view class="nav acea-row row-around"> <view class="nav acea-row row-around">
<view <view class="item" :class="screen.grade == 0 ? 'on' : ''" @click="checkGrade(0)">一级({{ first||'0' }})</view>
class="item" <view class="item" :class="screen.grade == 1 ? 'on' : ''" @click="checkGrade(1)">二级({{ second||'0' }})</view>
: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>
<view class="search acea-row row-between-wrapper"> <view class="search acea-row row-between-wrapper">
<form @submit.prevent="submitForm"> <form @submit.prevent="submitForm">
<view class="input"> <view class="input">
<input placeholder="点击搜索会员名称" v-model="screen.keyword" /> <input placeholder="点击搜索会员名称" v-model="screen.keyword" />
<text class="iconfont icon-guanbi"></text> <text class="iconfont icon-guanbi" @click="screen.keyword=''"></text>
</view> </view>
</form> </form>
<view class="iconfont icon-sousuo2"></view> <view class="iconfont icon-sousuo2"></view>
@ -56,11 +48,8 @@
</view> </view>
</view> </view>
<view :class="fixedState === true ? 'sortList' : ''"> <view :class="fixedState === true ? 'sortList' : ''">
<view <view class="item acea-row row-between-wrapper" v-for="(val, spreadListIndex) in spreadList"
class="item acea-row row-between-wrapper" :key="spreadListIndex">
v-for="(val, spreadListIndex) in spreadList"
:key="spreadListIndex"
>
<view class="picTxt acea-row row-between-wrapper"> <view class="picTxt acea-row row-between-wrapper">
<view class="pictrue"> <view class="pictrue">
<image :src="val.avatar" /> <image :src="val.avatar" />
@ -84,7 +73,9 @@
</view> </view>
</template> </template>
<script> <script>
import { getSpreadUser } from "@/api/user"; import {
getSpreadUser
} from "@/api/user";
import Loading from "@/components/Loading"; import Loading from "@/components/Loading";
export default { export default {
name: "PromoterList", name: "PromoterList",
@ -163,8 +154,7 @@ export default {
}, },
err => { err => {
uni.showToast({ uni.showToast({
title: title: err.msg || err.response.data.msg || err.response.data.message,
err.msg || err.response.data.msg || err.response.data.message,
icon: "none", icon: "none",
duration: 2000 duration: 2000
}); });

14
store/index.js

@ -39,14 +39,7 @@ const vuexStore = new Vuex.Store({
console.log('清除数据') console.log('清除数据')
state.token = null; state.token = null;
state.userInfo = null state.userInfo = null
let spread = cookie.get('spread')
let redirect = cookie.get('redirect')
let outTime = setTimeout(() => {
clearTimeout(outTime)
cookie.clearAll() cookie.clearAll()
cookie.set('redirect', redirect)
cookie.set('spread', spread)
}, 100)
}, },
backgroundColor(state, color) { backgroundColor(state, color) {
state.color = color; state.color = color;
@ -97,7 +90,7 @@ const vuexStore = new Vuex.Store({
userInfo({ state, commit }, force) { userInfo({ state, commit }, force) {
if (state.userInfo !== null && !force) { if (state.userInfo !== null && !force) {
return Promise.resolve(state.userInfo); return Promise.resolve(state.userInfo);
} else { }
return new Promise(reslove => { return new Promise(reslove => {
getUserInfo().then(res => { getUserInfo().then(res => {
commit("updateUserInfo", res.data); commit("updateUserInfo", res.data);
@ -110,9 +103,11 @@ const vuexStore = new Vuex.Store({
duration: 2000, duration: 2000,
}); });
}); });
}
}, },
getUser({ state, commit }) { getUser({ state, commit }) {
if (!state.token) {
return Promise.reject('未获取到token');
}
return new Promise(reslove => { return new Promise(reslove => {
getUserInfo().then(res => { getUserInfo().then(res => {
console.log(res) console.log(res)
@ -163,6 +158,7 @@ const vuexStore = new Vuex.Store({
location: state => state.location, location: state => state.location,
storeItems: state => state.storeItems, storeItems: state => state.storeItems,
goName: state => state.goName, goName: state => state.goName,
$deviceType: state => state.$deviceType,
}, },
strict: debug strict: debug
}); });

67
utils/index.js

@ -204,7 +204,6 @@ export const authorize = (authorizeStr) => {
} }
export const login = () => { export const login = () => {
console.log(Vue.prototype)
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (Vue.prototype.$deviceType == 'weixin') { if (Vue.prototype.$deviceType == 'weixin') {
// 微信授权登录 // 微信授权登录
@ -212,47 +211,32 @@ export const login = () => {
if (code) { if (code) {
auth(code) auth(code)
.then(() => { .then(() => {
// location.replace( let redirect = cookie.get('redirect')
// decodeURIComponent(decodeURIComponent(this.$route.params.url)) console.log(redirect)
// ); if (redirect) {
location.href = decodeURIComponent( redirect = redirect.split('/pages')[1]
decodeURIComponent(this.$route.params.url) reLaunch({
); path: '/pages' + redirect,
});
cookie.remove('redirect');
} else {
reLaunch({
path: '/pages/home/index',
});
}
}) })
.catch(() => { .catch(() => {
reject('当前运行环境为微信浏览器') reject('当前运行环境为微信浏览器')
location.replace("/pages/home/index"); reLaunch({
path: '/pages/home/index',
});
}); });
} else { } 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 return
} }
if (Vue.prototype.$deviceType == 'weixinh5') { if (Vue.prototype.$deviceType == 'weixinh5') {
console.log('当前运行环境为H5')
reject('当前运行环境为H5') reject('当前运行环境为H5')
return return
} }
@ -705,7 +689,8 @@ export const _router = {
push, push,
replace, replace,
go, go,
back back,
reLaunch
} }
@ -857,14 +842,18 @@ export const handleLoginFailure = () => {
console.log('————————') console.log('————————')
store.commit("logout"); store.commit("logout");
// 改为授权取消
store.commit("updateAuthorization", false); store.commit("updateAuthorization", false);
let currentPageUrl = getCurrentPageUrl() let currentPageUrl = getCurrentPageUrl()
if (store.state.$deviceType == 'weixin') { if (store.state.$deviceType == 'weixin') {
if (store.getters.isAuthorizationPage){ // 如果不是授权页面,
if (!store.getters.isAuthorizationPage) {
// 标识当前为授权页面
store.commit("updateAuthorizationPage", true);
toAuth() toAuth()
} }
return
} else { } else {
// token 失效 // token 失效
// 判断当前是不是已经在登录页面或者授权页,防止二次跳转 // 判断当前是不是已经在登录页面或者授权页,防止二次跳转
@ -900,7 +889,9 @@ export const handleLoginFailure = () => {
id: qrCode.pinkId, id: qrCode.pinkId,
} }
}) })
if (qrCode.spread) {
cookie.set("spread", qrCode.spread || 0); cookie.set("spread", qrCode.spread || 0);
}
} else { } else {
console.log('————————') console.log('————————')
console.log('是拼团进来的,但是没有获取到参数') console.log('是拼团进来的,但是没有获取到参数')
@ -923,7 +914,9 @@ export const handleLoginFailure = () => {
partake: qrCode.uid partake: qrCode.uid
} }
}) })
if (qrCode.spread) {
cookie.set("spread", qrCode.spread || 0); cookie.set("spread", qrCode.spread || 0);
}
} else { } else {
handleNoParameters() handleNoParameters()
console.log('————————') console.log('————————')
@ -944,7 +937,9 @@ export const handleLoginFailure = () => {
id: qrCode.productId, id: qrCode.productId,
} }
}) })
if (qrCode.spread) {
cookie.set("spread", qrCode.spread || 0); cookie.set("spread", qrCode.spread || 0);
}
} else { } else {
handleNoParameters() handleNoParameters()
console.log('————————') console.log('————————')

2
utils/request.js

@ -12,7 +12,7 @@ import Fly from "flyio/dist/npm/wx";
import Fly from "flyio/dist/npm/wx"; import Fly from "flyio/dist/npm/wx";
// #endif // #endif
import $store from "../store"; import store from "../store";
import { handleLoginFailure } from "@/utils"; import { handleLoginFailure } from "@/utils";
import { VUE_APP_API_URL } from "@/config"; import { VUE_APP_API_URL } from "@/config";
import cookie from "@/utils/store/cookie"; import cookie from "@/utils/store/cookie";

11
utils/store/cookie.js

@ -29,7 +29,16 @@ function remove(key) {
} }
function clearAll() { 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) { function _has(key) {

Loading…
Cancel
Save