Browse Source

添加推广功能、第二版

master
前端-胡立永 9 months ago
parent
commit
beb907a077
8 changed files with 425 additions and 75 deletions
  1. +1
    -1
      App.vue
  2. +11
    -6
      api/api.js
  3. +5
    -0
      main.js
  4. +46
    -7
      pages/center/center.vue
  5. +128
    -29
      pages/payment/payment.vue
  6. +182
    -16
      pages/promotion/promotion.vue
  7. +4
    -4
      pages/weddingCelebration/weddingCelebration.vue
  8. +48
    -12
      store/store.js

+ 1
- 1
App.vue View File

@ -4,7 +4,7 @@
this.$store.commit('initConfig')
},
onShow: function() {
// this.$store.commit('initConfig')
this.$store.commit('getGasStationList')
},
onHide: function() {
}


+ 11
- 6
api/api.js View File

@ -10,13 +10,13 @@ const config = {
// 获取个人信息接口
infoGetInfo: { url: '/cheer/info/getInfo', method: 'GET', auth: true, showLoading : true },
//下单
createOrderPay: { url: '/cheer/info/createOrderPay', method: 'GET', auth: true, limit : 2000, showLoading : true },
// createOrderPay: { url: '/cheer/info/createOrderPay', method: 'GET', auth: true, limit : 2000, showLoading : true },
//获取折扣、客户电话、微信
getConfig: { url: '/cheer/info/getConfig', method: 'GET'},
// getConfig: { url: '/cheer/info/getConfig', method: 'GET'},
//获取充值套餐
getRechargePage: { url: '/cheer/info/getRechargePage', method: 'GET'},
// getRechargePage: { url: '/cheer/info/getRechargePage', method: 'GET'},
//获取加油流水订单
getOrderWaterPage: { url: '/cheer/info/getOrderWaterPage', method: 'GET', showLoading : true },
// getOrderWaterPage: { url: '/cheer/info/getOrderWaterPage', method: 'GET', showLoading : true },
//获取隐私政策
getPrivacyPolicy: { url: '/cheer/login/getPrivacyPolicy', method: 'GET'},
//获取用户协议
@ -24,7 +24,7 @@ const config = {
/**
* 新版本接口
* 新版本接口
*/
//根据加油站标识获取相关配置信息
twogetConfig: { url: '/cheer/two/getConfig', method: 'GET'},
@ -34,10 +34,15 @@ const config = {
twogetOrderWaterPage: { url: '/cheer/two/getOrderWaterPage', method: 'GET'},
//根据加油站标识获取加油站充值套餐信息
twogetRechargeList: { url: '/cheer/two/getRechargeList', method: 'GET'},
//获取推广二维码
getQrCode: { url: '/cheer/two/getQrCode', method: 'GET'},
//查询当前用户是否是管理员
isAdmin: { url: '/cheer/two/isAdmin', method: 'GET'},
//用户输入支付创建支付订单并且支付
twocreateOrderPay: { url: '/cheer/two/createOrderPay', method: 'POST'},
}
export function api(key, data, callback, loadingTitle) {
let req = config[key]


+ 5
- 0
main.js View File

@ -5,6 +5,7 @@ import Vue from 'vue'
import './uni.promisify.adaptor'
Vue.config.productionTip = false
App.mpType = 'app'
@ -15,6 +16,7 @@ import i18n from './locale/index.js'
import './config'
import './utils/index.js'
//组件注册
import configPopup from '@/components/config/configPopup.vue'
import changeLanguage from '@/components/base/changeLanguage.vue'
@ -28,6 +30,9 @@ const app = new Vue({
i18n
})
app.$mount()
// #endif
// #ifdef VUE3


+ 46
- 7
pages/center/center.vue View File

@ -37,20 +37,41 @@
登录 / 注册
</view>
</view>
<view style="margin-left: auto;
color: #00aaff;"
@click="toPromotion">
推广
</view>
</view>
</view>
<view class="listBox">
<view class="lists">
<!-- <uni-section @click="toPromotion" title="推广" type="line" titleFontSize="34rpx"
<!-- <uni-section v-if="isAdminResult" @click="toPromotion" title="推广" type="line" titleFontSize="34rpx"
style="border-radius: 10rpx;"></uni-section> -->
<!-- <view class="">
<uv-cell icon="setting-fill"
iconStyle="font-size: 36rpx;"
isLink
title="个人设置"></uv-cell>
</view> -->
<!-- <view class="order-item">
<div class="order-item-main">
<div class="title">推广二维码</div>
</div>
</view> -->
<uni-section title="我的订单" type="line" titleFontSize="34rpx"
style="border-radius: 10rpx;"></uni-section>
<view class="order-list">
<view v-for="(item,index) in orderList" :key="item.id" class="order-item">
<view class="order-item-top">
<view class="order-id">{{ item.id }}</view>
<view class="time">{{ item.createTime }}</view>
<view class="time">{{ item.state_dictText }}</view>
</view>
<div class="order-item-main">
<div class="title">付款金额</div>
@ -60,6 +81,15 @@
<view class="oldPrice">{{ item.oldPrice }}</view>
</view>
</div>
<view class="order-item-top">
<view class="order-id">订单号{{ item.id }}</view>
</view>
<view class="order-item-top">
<view class="order-id">站点{{ item.shopId }}</view>
</view>
<view class="order-item-top">
<view class="order-id">油号{{ item.name }}</view>
</view>
</view>
</view>
<view v-if="false" class="no-data">
@ -87,13 +117,15 @@
pageSize: 10
},
orderList: [],
total: 0
total: 0,
isAdminResult : false,
}
},
onShow() {
if (uni.getStorageSync('token')) {
this.$store.commit('getUserInfo')
this.getOrderList()
this.isAdmin()
}
},
//
@ -106,11 +138,19 @@
methods: {
//
getOrderList() {
this.$api('getOrderWaterPage', this.queryParams, res => {
this.$api('twogetOrderWaterPage', this.queryParams, res => {
this.orderList = res.result.records
this.total = res.result.total
})
},
//
isAdmin() {
this.$api('isAdmin', res => {
if(res.code == 200){
this.isAdminResult = !!res.result
}
})
},
//广
toPromotion(){
@ -216,20 +256,19 @@
}
.order-item {
width: 100%;
background: white;
border-radius: 20rpx;
margin-bottom: 20rpx;
padding: 20rpx;
}
.order-item .order-item-top {
display: flex;
align-items: center;
justify-content: space-between;
height: 80rpx;
font-size: 24rpx;
box-sizing: border-box;
padding: 0rpx 20rpx;
padding: 10rpx 20rpx;
}
.order-item .order-item-main {


+ 128
- 29
pages/payment/payment.vue View File

@ -4,13 +4,42 @@
<view class="container">
{{ scene }}
<uni-section title="当前加油站"
type="line"
titleFontSize="34rpx"></uni-section>
<view class="select-oil"
style="justify-content: flex-start;">
<view class="oil-item" v-if="gasStation.name">
<view class="oil active-oil">
{{ gasStation.name }}
</view>
</view>
<view class="oil-item"
style="margin-left: 20rpx;">
<view class="oil"
style="display: flex;
justify-content: center;
align-items: center;
height: 100%;"
@click="$refs.popup.open()">
选择站点
</view>
</view>
</view>
<!-- <view class="tip">
{{ gasStation.name }}
</view> -->
<uni-section title="油号" type="line" titleFontSize="34rpx"></uni-section>
<view class="select-oil">
<view class="oil-item">
<view class="oil active-oil"
style="flex-direction: column;">
<view class="number">{{ configList.title.keyCentent }}</view>
<view class="unit">{{ configList.price.keyCentent }}</view>
<view class="number">{{ configList.title }}</view>
<view class="unit">{{ configList.price }}</view>
</view>
</view>
</view>
@ -25,7 +54,7 @@
折后共计{{
(form.money *
(configList.preferential ?
configList.preferential.keyCentent
configList.preferential
: 1)).toFixed(2)
}}
</view>
@ -53,12 +82,35 @@
@trigger="clickMenu" /> -->
<view class="phone"
@click="clickService(configList.phone.keyCentent)">
@click="clickService(configList.phone)">
<uv-icon
size="45rpx"
color="#fff"
name="phone"></uv-icon>
</view>
<uv-popup ref="popup"
:round="30"
:closeOnClickOverlay="false"
:customStyle="{'max-height': '80vh'}">
<view class="GasStationList">
<view class="title">
请选择加油站
</view>
<view class="select-oilx">
<view class="oil-itemx"
@click="setGasStation(item)"
:key="index"
v-for="(item, index) in gasStationList">
<view class="oilx">
{{ item.name }}
</view>
</view>
</view>
</view>
</uv-popup>
</view>
</template>
@ -72,7 +124,7 @@
PrivacyAgreementPoup
},
computed : {
...mapState(['configList']),
...mapState(['configList', 'gasStationList', 'gasStation']),
},
data() {
return {
@ -90,32 +142,40 @@
horizontal: 'right',
vertical: 'bottom',
direction: 'vertical',
rechargeList : []
rechargeList : [],
scene : '',
}
},
onShow() {
// if (wx.onNeedPrivacyAuthorization) {
// console.log('onNeedPrivacyAuthorization');
// wx.onNeedPrivacyAuthorization(resolve => {
// console.log('onNeedPrivacyAuthorization');
// this.resolvePrivacyAuthorization = resolve
// this.$refs.showPrivacy.init(resolve)
// })
// }
// wx.getPrivacySetting({
// success: res => {
// console.log(res)
// if (res.needAuthorization) {
// //
// this.$refs.showPrivacy.init()
// }
// },
// fail: () => {}
// })
this.getRechargePage()
if(!this.scene && !this.gasStation.id){
this.$refs.popup.open()
}else{
this.gasStationList.forEach(n => {
if(n.id == this.scene){
this.$store.commit('setGasStation', n)
}
})
this.$nextTick(n => {
this.getRechargePage()
})
}
},
onLoad (query) {
// scene 使 decodeURIComponent scene
const scene = decodeURIComponent(query.scene || '')
this.scene = scene
},
methods: {
setGasStation(data){
this.$store.commit('setGasStation', data)
this.$refs.popup.close()
this.$nextTick(n => {
this.getRechargePage()
})
},
//
selectMoney(money, item) {
this.form.money = money
@ -137,6 +197,9 @@
},
submit() {
if (!this.gasStation.id) {
return this.$refs.popup.open()
}
if (!uni.getStorageSync('token')) {
return uni.navigateTo({
url: '/pages/login/login'
@ -144,7 +207,7 @@
}
let money = (this.form.money *
(this.configList.preferential ?
this.configList.preferential.keyCentent
this.configList.preferential
: 1)).toFixed(2)
// if(!money){
@ -154,8 +217,9 @@
// })
// }
this.$api('createOrderPay', {
money
this.$api('twocreateOrderPay', {
money,
shopId : this.gasStation.id,
}, res => {
this.form.money = ''
if(res.code == 200){
@ -191,7 +255,9 @@
//
getRechargePage(){
this.$api('getRechargePage', res => {
this.$api('twogetRechargeList', {
id : this.gasStation.id
}, res => {
this.rechargeList = res.result.records
})
},
@ -210,10 +276,43 @@
<style scoped lang="scss">
.payment {
/deep/ .uv-popup{
z-index: 99999999 !important;
}
height: 100vh;
background: #F1F5F8;
width: 750rpx;
margin: 0 auto;
.GasStationList{
width: 650rpx;
text-align: center;
max-height: calc(80vh - 20rpx);
overflow: auto;
.title{
padding: 20rpx;
font-size: 35rpx;
margin-top: 10rpx;
font-weight: 900;
position: sticky;
top: 0;
background-color: #fff;
}
.oil-itemx{
width: auto;
box-sizing: border-box;
border-radius: 20rpx;
margin: 20rpx;
padding: 30rpx 20rpx;
overflow: hidden;
background-color: #00aaff;
.oilx{
align-items: flex-start;
padding: 20rpx;
font-size: 30rpx;
color: #fff;
}
}
}
.container{
.oil-item{
.active-oil{


+ 182
- 16
pages/promotion/promotion.vue View File

@ -1,21 +1,29 @@
<template>
<view class="promotion">
<uni-nav-bar dark :fixed="true" background-color="#00aaff" :border="false" status-bar title="推广" />
<uni-nav-bar dark :fixed="true" background-color="#00aaff" :border="false" status-bar title="推广"
@clickLeft="back" left-icon="left" />
<view class="promotion-card">
<view class="user-info">
<!-- <image :src="userInfo.headImage" mode=""></image> -->
<image class="image" src="../../static/logo.png" mode="widthFix"></image>
<!-- <view class="user-name">{{ userInfo.nickName }}</view> -->
<view class="user-name">湖南第一深情</view>
</view>
<view class="invitation-code-img">
<image class="image" src="../../static/logo.png" mode="widthFix"></image>
</view>
<view class="invitation-code">邀请码: sjflshf</view>
<!-- <view class="user-info"> -->
<!-- <image class="image" :src="userInfo.headImage" mode="widthFix"></image> -->
<!-- <image class="image" src="../../static/logo.png" mode="widthFix"></image> -->
<!-- <view class="user-name">{{ userInfo.nickName }}</view> -->
<!-- <view class="user-name">湖南第一深情</view> -->
<!-- </view> -->
<!-- <view class="invitation-code-img">
<image
style="width: 400rpx;"
:src="imagePath" mode="widthFix"></image>
</view> -->
<image style="width: 100%;" :src="imagePath" mode="widthFix"></image>
<!-- <view class="invitation-code">加油站: {{ title }}</view> -->
<canvas id="myCanvas" type="2d" canvas-id="firstCanvas1"></canvas>
</view>
<view class="btns">
<view class="btn">保存海报</view>
<view class="btn">立即邀请</view>
<view class="btn"
@click="preservationImg(imagePath)">保存海报</view>
<!-- <view class="btn">立即邀请</view> -->
</view>
</view>
</template>
@ -31,11 +39,155 @@
},
data() {
return {
url: '',
title: '123123',
baseUrl: 'https://dianpin-img.xzaiyp.top/',
canvas: {},
imagePath: '',
}
},
onShow() {
this.getQrCode()
this.$store.commit('getUserInfo')
},
methods: {
getQrCode() {
this.$api('getQrCode', res => {
if (res.code == 200) {
this.url = res.result.url
this.title = res.result.name
this.draw()
}
})
},
draw() {
uni.showLoading({
title: "拼命绘画中..."
})
wx.createSelectorQuery()
.select('#myCanvas') // canvasid
.fields({
node: true,
size: true
})
.exec((res) => {
const canvas = res[0].node
//
const ctx = canvas.getContext('2d')
// Canvas
const width = res[0].width
const height = res[0].height
//
const dpr = wx.getWindowInfo().pixelRatio
//dpr
// dpr 2 4
// 3 6
let Ratio = dpr * 2
console.log("bug", dpr)
canvas.width = width * dpr
canvas.height = height * dpr
this.canvas = canvas
ctx.scale(dpr, dpr)
ctx.clearRect(0, 0, width, height)
ctx.fillStyle = '#fff'
ctx.fillRect(0, 0, canvas.width, canvas.height)
//
// const image = canvas.createImage()
// image.onload = () => {
// ctx.drawImage(image, 30, 18, 40, 40)
// }
// image.src = '/public/img/wechar_1.png'
// image.src = this.userInfo.headImage
ctx.fillStyle = 'black'
ctx.font = '22px PingFangSC-regular';
let s = this.title || '加油站'
ctx.fillText(s, canvas.width / Ratio - s.length * 11, 50);
//
const coderImage = canvas.createImage()
coderImage.src = this.baseUrl + this.url
coderImage.onload = () => {
ctx.drawImage(coderImage,
canvas.width / Ratio - 240 / 2, 100, 240, 240)
}
//
setTimeout(() => {
wx.canvasToTempFilePath({
x: 0,
y: 0,
width: this.canvas.width,
height: this.canvas.height,
canvas,
success: (res) => {
var tempFilePath = res.tempFilePath;
this.imagePath = tempFilePath
uni.hideLoading()
}
});
}, 600);
})
},
back() {
uni.navigateBack(-1)
},
preservationImg(img) {
let that = this
uni.authorize({
/* scope.writePhotosAlbum 类型是保存到相册 */
scope: 'scope.writePhotosAlbum',
success() {
/* 已授权进入 */
/* 保存图片到相册方法方法 */
that.imgApi(img);
},
complete(res) {
/* 判断如果没有授权就打开设置选项让用户重新授权 */
uni.getSetting({
success(res) {
if (!res.authSetting['scope.writePhotosAlbum']) {
/* 打开设置的方法 */
that.openInstall();
}
}
});
}
});
},
imgApi(image) {
/* 获取图片的信息 */
uni.getImageInfo({
src: image,
success: function(image) {
/* 保存图片到手机相册 */
uni.saveImageToPhotosAlbum({
filePath: image.path,
success: function() {
uni.showModal({
title: '保存成功',
content: '图片已成功保存到相册',
showCancel: false
});
},
complete(res) {
console.log(res);
}
});
}
});
},
}
}
</script>
@ -90,14 +242,14 @@
left: 0;
bottom: 0;
width: 100%;
height: 90rpx;
height: 120rpx;
display: flex;
background: #00aaff;
color: white;
font-size: 28rpx;
.btn {
width: 50%;
flex: 1;
display: flex;
align-items: center;
justify-content: center;
@ -108,4 +260,18 @@
}
}
}
#myCanvas {
position: fixed;
left: 100%;
/* visibility: hidden */
/* visibility: hidden; */
/* margin-top: 100rpx; */
margin: 68rpx auto;
width: 750rpx;
height: 750rpx;
/* line-height: 20px; */
background-color: rgba(255, 255, 255, 1);
text-align: center;
}
</style>

+ 4
- 4
pages/weddingCelebration/weddingCelebration.vue View File

@ -5,21 +5,21 @@
<uni-card :is-shadow="false">
<view class="weixin-top">
<view class="title">微信号:</view>
<view @click="copy(configList.wx.keyCentent)" class="copy icon">
<view @click="copy(configList.wx)" class="copy icon">
<image src="@/static/weddingCelebration/copy.png" mode="widthFix"></image>
</view>
</view>
<view class="number">{{ configList.wx.keyCentent }}</view>
<view class="number">{{ configList.wx }}</view>
</uni-card>
<uni-card :is-shadow="false">
<view class="weixin-top">
<view class="title">手机号:</view>
<view @click="clickService(configList.phone.keyCentent)" class="copy icon">
<view @click="clickService(configList.phone)" class="copy icon">
<image src="@/static/weddingCelebration/phone.png" mode="widthFix"></image>
</view>
</view>
<view class="number">{{ configList.phone.keyCentent }}</view>
<view class="number">{{ configList.phone }}</view>
</uni-card>
</uni-section>
</view>


+ 48
- 12
store/store.js View File

@ -8,8 +8,18 @@ import api from '@/api/api.js'
//Vuex.Store 构造器选项
const store = new Vuex.Store({
state: {
configList: {}, //配置对象
configList: {
phone: "",
preferential: 1,
price: 6.66,
privacyAgreement: "隐私政策",
title: "#95",
userAgreement: "用户协议",
wx: "",
}, //配置对象
userInfo : {},
gasStationList : [],
gasStation : {},
},
getters: {
getConfig(state){
@ -19,16 +29,16 @@ const store = new Vuex.Store({
mutations: {
// 初始化配置
initConfig(state) {
let config = ['preferential', 'wx', 'phone', 'price', 'title']
config.forEach(k => {
api('getConfig', {
keyValue : k
}, res => {
if (res.code == 200) {
state.configList[k] = res.result
}
})
})
// let config = ['preferential', 'wx', 'phone', 'price', 'title']
// config.forEach(k => {
// api('getConfig', {
// keyValue : k
// }, res => {
// if (res.code == 200) {
// state.configList[k] = res.result
// }
// })
// })
let apiConfig = [ 'getPrivacyPolicy' , 'getUserAgreement' ] //需要访问不同接口才能得到的配置数据
let key = ['privacyAgreement','userAgreement']
@ -38,13 +48,39 @@ const store = new Vuex.Store({
})
})
},
twogetConfig(state){
api('twogetConfig', {
shopId : state.gasStation.id
}, res => {
if (res.code == 200) {
['preferential', 'wx', 'phone', 'price', 'title']
.forEach(n => {
state.configList[n] = res.result[n]
})
}
})
},
//获取加油站列表
getGasStationList(state){
api('getGasStationList', {
pageNo : 1,
pageSize : 9999999
}, res => {
if(res.code == 200){
state.gasStationList = res.result.records
}
})
},
setGasStation(state, data){
state.gasStation = data
this.commit('twogetConfig')
},
login(state) {
uni.showLoading({
title:"登录中..."
})
uni.login({
success(res) {
console.log(res);
if (res.errMsg != "login:ok") {
return
}


Loading…
Cancel
Save