Browse Source

上传

master
前端-胡立永 3 days ago
parent
commit
4549fc85dd
7 changed files with 190 additions and 43 deletions
  1. +3
    -0
      App.vue
  2. +123
    -0
      components/config/loginPopup.vue
  3. +2
    -2
      pages/index/center.vue
  4. +16
    -9
      pages_order/mine/promotion.vue
  5. +13
    -25
      pages_order/order/instantGift.vue
  6. +12
    -1
      pages_order/order/receiveGift.vue
  7. +21
    -6
      store/store.js

+ 3
- 0
App.vue View File

@ -3,6 +3,9 @@
onLaunch: function() {
this.$store.commit('initConfig')
this.$store.commit('getCategoryList')
if(uni.getStorageSync('token')){
this.$store.commit('getQrCode')
}
},
onShow: function() {
},


+ 123
- 0
components/config/loginPopup.vue View File

@ -0,0 +1,123 @@
<template>
<uv-popup ref="loginPopup"
mode="center"
:round="20"
:closeable="false"
:maskClick="false"
:closeOnClickOverlay="false"
:customStyle="{backgroundColor: '#fff', padding: 0}"
overlayOpacity="0.8">
<view class="login-card">
<view class="login-title">登录后即可领取礼物</view>
<view class="login-content">
<!-- <image :src="logo_image" mode="aspectFit" class="login-image"></image> -->
<button class="login-btn" @click="handleLogin">
微信一键登录
</button>
</view>
</view>
</uv-popup>
</template>
<script>
export default {
data(){
return {
logo_image : '',
}
},
created() {
this.logo_image = this.configList.logo_image
uni.$on('initConfig', data => {
this.logo_image = data.logo_image
})
},
methods: {
open(){
this.$refs.loginPopup.open()
},
close(){
this.$refs.loginPopup.close()
},
//
handleLogin() {
uni.showLoading({
title: '登录中...'
})
uni.login({
success : (res) => {
if (res.errMsg != "login:ok") {
return
}
let data = {
code: res.code,
}
if (uni.getStorageSync('shareId')) {
data.shareId = uni.getStorageSync('shareId')
}
this.$api('wxLogin', data, res => {
uni.hideLoading()
if (res.code != 200) {
this.close()
return
}
uni.setStorageSync('token', res.result.token)
this.close()
this.$emit('login')
})
}
})
},
}
}
</script>
<style lang="scss" scoped>
.login-card {
width: 600rpx;
padding: 40rpx;
text-align: center;
.login-title {
font-size: 32rpx;
font-weight: bold;
color: #333;
margin-bottom: 40rpx;
}
.login-content {
.login-image {
width: 300rpx;
height: 300rpx;
margin-bottom: 40rpx;
}
.login-btn {
display: flex;
align-items: center;
justify-content: center;
margin: 0 auto;
width: 80%;
height: 88rpx;
background: #07C160;
color: #fff;
border-radius: 44rpx;
font-size: 32rpx;
.wechat-icon {
width: 48rpx;
height: 48rpx;
margin-right: 10rpx;
}
}
}
}
</style>

+ 2
- 2
pages/index/center.vue View File

@ -218,9 +218,9 @@
logout(){
uni.showModal({
title: '确认退出登录吗',
success(r) {
success : (r) => {
if (r.confirm) {
this.$store.commit('logout')
this.$store.commit('logout', true)
}
}
})


+ 16
- 9
pages_order/mine/promotion.vue View File

@ -9,7 +9,7 @@
<image
class="image"
:src="imagePath" mode="aspectFill"></image>
:src="promotionUrl" mode="aspectFill"></image>
<canvas id="myCanvas" type="2d" canvas-id="firstCanvas1"></canvas>
@ -42,24 +42,31 @@ import index from '../../uni_modules/uv-ui-tools'
},
onShow() {
let that = this;
if(that.promotionUrl){
that.imagePath = that.promotionUrl
console.log("当前地址:"+that.imagePath)
}else{
that.getQrCode()
if(!that.promotionUrl){
// that.getQrCode()
uni.showLoading({
title: "拼命绘画中..."
})
}
that.$store.commit('getUserInfo')
},
methods: {
getQrCode() {
uni.showLoading({
title: "拼命绘画中..."
})
let that = this;
that.$api('getInviteCode', res => {
if (res.code == 200) {
console.log("----------")
console.log(res)
that.url = res.result.url
that.title = res.result.name
that.draw()
that.imagePath = that.$config.aliOss.url + res.result.url
that.$store.commit('setPromotionUrl', that.imagePath)
// that.draw()
uni.hideLoading()
}
})
},


+ 13
- 25
pages_order/order/instantGift.vue View File

@ -70,42 +70,30 @@
}
},
onShareAppMessage(res) {
let o = {
title : this.blessing || this.giveTitle,
path : '/pages_order/order/receiveGift?id=' + this.id,
imageUrl : this.giftList[this.selectedIndex].image,
}
if(this.userInfo.id){
o.path += '&shareId=' + this.userInfo.id
}
return o
return this.getShareData(res)
},
//2.
onShareTimeline(res) {
let o = {
title : this.blessing || this.giveTitle,
path : '/pages_order/order/receiveGift?id=' + this.id,
imageUrl : this.giftList[this.selectedIndex].image,
}
if(this.userInfo.id){
o.path += '&shareId=' + this.userInfo.id
}
return o
return this.getShareData(res)
},
methods: {
getShareData(res){
let o = {
title : `${this.configList.logo_name}用户${this.userInfo.nickName}挑选了1份礼物送给你,请收下这份心意`,
path : '/pages_order/order/receiveGift?id=' + this.id,
imageUrl : this.giftList[this.selectedIndex].image,
}
if(this.userInfo.id){
o.path += '&shareId=' + this.userInfo.id
}
return o
},
navigateBack() {
uni.navigateBack()
},
selectGift(index) {
this.selectedIndex = index
},
sendGift() {
//
uni.showToast({
title: '送礼成功',
icon: 'success'
})
},
//
getRiceBlessing(){
this.$api('getRiceBlessing')


+ 12
- 1
pages_order/order/receiveGift.vue View File

@ -158,16 +158,20 @@
</view>
</uv-popup>
<loginPopup ref="loginPopup" @login="getGiftInfo"/>
</view>
</template>
<script>
import addressList from '../components/address/addressList.vue'
import redactAddressForm from '../components/address/redactAddressForm.vue'
import loginPopup from '@/components/config/loginPopup.vue'
export default {
components : {
addressList,
redactAddressForm,
loginPopup,
},
data() {
return {
@ -333,9 +337,16 @@
},
},
onLoad(options) {
if (options.shareId) {
uni.setStorageSync('shareId', options.shareId)
}
if (options.id) {
this.giftId = options.id
this.getGiftInfo()
if(uni.getStorageSync('token')){
this.getGiftInfo()
}else{
this.$refs.loginPopup.open()
}
}
},
onShow() {


+ 21
- 6
store/store.js View File

@ -20,7 +20,9 @@ const store = new Vuex.Store({
// 初始化配置
initConfig(state) {
api('getConfig', res => {
const configList = {};
const configList = {
...state.configList,
}
if (res.code == 200) {
res.result.forEach(n => {
configList[n.keyName] = n.keyContent;
@ -28,6 +30,7 @@ const store = new Vuex.Store({
});
}
state.configList = configList
uni.$emit('initConfig', state.configList)
})
// let config = ['getPrivacyPolicy', 'getUserAgreement']
@ -39,7 +42,7 @@ const store = new Vuex.Store({
// })
// })
},
login(state, phoneCode) {
login(state, config) {
uni.showLoading({
title: '登录中...'
})
@ -51,7 +54,6 @@ const store = new Vuex.Store({
let data = {
code: res.code,
phoneCode,
}
if (uni.getStorageSync('shareId')) {
@ -118,7 +120,7 @@ const store = new Vuex.Store({
})
},
// 退出登录
logout(state) {
logout(state, reLaunch = false) {
// uni.showModal({
// title: '确认退出登录吗',
// success(r) {
@ -131,10 +133,23 @@ const store = new Vuex.Store({
// }
// }
// })
state.userInfo = {}
uni.removeStorageSync('token')
uni.reLaunch({
url: '/pages/index/index'
if(reLaunch){
uni.reLaunch({
url: '/pages/index/index'
})
}
},
getQrCode(state) {
api('getInviteCode', res => {
if (res.code == 200) {
state.promotionUrl = Vue.prototype.$config.aliOss.url + res.result.url
}
uni.hideLoading()
})
},
// 查询分类接口


Loading…
Cancel
Save