Browse Source

抽奖分享

master
396316021 1 year ago
parent
commit
a484e2b16e
  1. 2
      api/coupons.js
  2. 4
      api/draw.js
  3. 6
      config/host.js
  4. 88
      pages/Coupons/index.vue
  5. 4
      pages/Draw/index.vue
  6. 11
      utils/request.js

2
api/coupons.js

@ -8,7 +8,7 @@ export function couponsList(data) {
url: `${host}/coupons/coupons-list`, url: `${host}/coupons/coupons-list`,
method: "get", method: "get",
data data
}); },false);
} }
export function obtainCoupons(data) { export function obtainCoupons(data) {

4
api/draw.js

@ -2,10 +2,10 @@ import request from "@/utils/request";
import requestOther from "@/utils/requestOther"; import requestOther from "@/utils/requestOther";
export function drawList(){ export function drawList(){
return requestOther({ return request({
url:'draw/drawgoods-list', url:'draw/drawgoods-list',
method:'post', method:'post',
}) },false)
} }
export function getDraw(data){ export function getDraw(data){
return request({ return request({

6
config/host.js

@ -1,6 +1,6 @@
// const host='http://192.168.2.92:9505/api' // const host='http://192.168.2.92:9509/api'
// const host='https://weiyang.test.scyp.ink/api' const host='https://weiyang.test.scyp.ink/api'
const host='https://wechat.wwxtx.com/api' // const host='https://wechat.wwxtx.com/api'
// const host='https://bml.test.scyp.ink/api' // const host='https://bml.test.scyp.ink/api'
// const host='http://192.168.2.92:9503/api' // const host='http://192.168.2.92:9503/api'
// const imghost='https://weiyang.test.scyp.ink/static/image' // const imghost='https://weiyang.test.scyp.ink/static/image'

88
pages/Coupons/index.vue

@ -87,7 +87,56 @@
<u-parse :content="couponsContent"></u-parse> <u-parse :content="couponsContent"></u-parse>
</view> </view>
</uv-popup> </uv-popup>
<!-- <RightNav></RightNav> --> <uv-popup z-index="10000" ref="notOpenPop" mode="center" round="20rpx" closeable safeAreaInsetTop safeAreaInsetBottom custom-style="width:80%;position:relative;">
<view class="title row" style="position:absolute;justify-content: flex-start;width:100%;top:20rpx;left:0;">
<view class="value col" style="position: relative;text-align: center;">
<!-- <u-text text="协议内容" size="38" color="#191919"></u-text>-->
<view class="" style="position: relative;display:inline-block;">
<view style="color:#191919;font-size:38rpx;display:inline-block;position: relative;z-index: 2;">提示</view>
<view class="background" style="width:100%;height:50%;position: absolute;bottom:0;left:0;background-color:rgba(227, 191, 119, 0.6);display:inline-block;z-index:1;"></view>
</view>
</view>
</view>
<view style="padding:30rpx 30rpx 0;max-height:700rpx;overflow: auto;">
<view style="height:100rpx;display: flex;align-items: center;justify-content: center;">当前不在活动时间内 </view>
<view class="row">
<!-- <view class="col-6">-->
<!-- <MzButton title="取消" @click="() => {}"></MzButton>-->
<!-- </view>-->
<view class="col-12">
<MzButton title="确认" @click="navTo('/pages/Index/index')" button-color="#4DC3B8" font-color="#fff"></MzButton>
</view>
</view>
</view>
</uv-popup>
<uv-popup z-index="10000" ref="notLoginPop" mode="center" round="20rpx" closeable safeAreaInsetTop safeAreaInsetBottom custom-style="width:80%;position:relative;">
<view class="title row" style="position:absolute;justify-content: flex-start;width:100%;top:20rpx;left:0;">
<view class="value col" style="position: relative;text-align: center;">
<!-- <u-text text="协议内容" size="38" color="#191919"></u-text>-->
<view class="" style="position: relative;display:inline-block;">
<view style="color:#191919;font-size:38rpx;display:inline-block;position: relative;z-index: 2;">提示</view>
<view class="background" style="width:100%;height:50%;position: absolute;bottom:0;left:0;background-color:rgba(227, 191, 119, 0.6);display:inline-block;z-index:1;"></view>
</view>
</view>
</view>
<view style="padding:30rpx 30rpx 0;max-height:700rpx;overflow: auto;">
<view style="height:100rpx;display: flex;align-items: center;justify-content: center;">当前未登录是否前往登录 </view>
<view class="row">
<view class="col-6" style="padding:0 15rpx;">
<MzButton title="取消" @click="navTo('/pages/Index/index')"></MzButton>
</view>
<view class="col-6" style="padding:0 15rpx;">
<MzButton title="确认" @click="() => {
this.navTo('/pages/Login/index');
this.$refs.notLoginPop.close();
}" button-color="#4DC3B8" font-color="#fff"></MzButton>
</view>
</view>
</view>
</uv-popup>
<!-- <RightNav></RightNav> -->
</template> </template>
<script> <script>
@ -116,6 +165,7 @@
}, },
data() { data() {
return { return {
showModal:false,
title: 'Hello', title: 'Hello',
loading: true, loading: true,
staticImage: { staticImage: {
@ -150,24 +200,50 @@
status:'loadmore', status:'loadmore',
navToUrl:'', navToUrl:'',
couponsContent:'', couponsContent:'',
is_open_draw:false,
} }
}, },
onLoad(option) { onLoad(option) {
this.type = option.type||'lists' this.type = option.type||'lists'
console.log(this.type)
this.navToUrl = option.url || '' this.navToUrl = option.url || ''
this.couponType = parseInt(option.coupon_type) || 2
}, },
onShareAppMessage() {
// if(!this.is_open_draw){
// return false;
// }
return {
title:'优惠在这',
path:'/pages/Coupons/index?coupon_type=1&type=draw',
}
},
onShareTimeline() {
// if(!this.is_open_draw){
// return false;
// }
return {
title:'优惠在这',
path:'/pages/Index/index?coupon_type=1&type=draw',
}
},
methods: { methods: {
getDrawList(){ getDrawList(){
drawList().then(data => { drawList().then(data => {
if(data.code === 200){ if(data.code === 200){
if(data.data.goodslists.length > 0){ if(data.data.goodslists.length > 0){
this.types = [ this.types = [
{title:'省点银子', value: 2}, {title:'省点银子', value: 2},
{title:'宝藏挖掘机', value: 1}, {title:'宝藏挖掘机', value: 1},
]; ];
}else {
if(this.type === 'draw'){
this.$refs.notOpenPop.open();
}
} }
} }
}).catch(err => {
this.$refs.notLoginPop.open();
}); });
}, },
showCoupons(item){ showCoupons(item){
@ -238,7 +314,9 @@
return; return;
} }
this.couponsList.push(...couponsList); this.couponsList.push(...couponsList);
}) }).catch(err => {
this.$refs.notLoginPop.open();
});
}, },
couponTypeToggle(item){ couponTypeToggle(item){
this.couponType = item.value; this.couponType = item.value;
@ -246,9 +324,11 @@
this.status = 'loadmore'; this.status = 'loadmore';
if(item.value === 1){ if(item.value === 1){
this.type = 'draw'; this.type = 'draw';
this.is_open_draw = true;
return; return;
}else{ }else{
this.type = 'lists'; this.type = 'lists';
this.is_open_draw = false;
} }
this.getCouponsList(); this.getCouponsList();
} }
@ -267,7 +347,7 @@
// this.pagePadding = (api.navHeight().navPaddingTop + // this.pagePadding = (api.navHeight().navPaddingTop +
// api.navHeight().navHeight + (api.navHeight().headerPadding * 2)) // api.navHeight().navHeight + (api.navHeight().headerPadding * 2))
}, },
mounted() { onShow() {
this.getCouponsList(); this.getCouponsList();
this.getDrawList(); this.getDrawList();
} }

4
pages/Draw/index.vue

@ -13,7 +13,9 @@
<view class="" style="width:95rpx;height:95rpx;display: inline-block;"> <view class="" style="width:95rpx;height:95rpx;display: inline-block;">
<u-image width="83" height="83" class="img" mode="aspectFill" :src="item.logo"></u-image> <u-image width="83" height="83" class="img" mode="aspectFill" :src="item.logo"></u-image>
</view> </view>
<view class="draw-title ">{{ item.title }}</view> <view class="draw-title ">
<u-text align="center" :lines="1" :text="item.title" :color="(checked === index)?'#fff':'#539188'" size="26rpx"></u-text>
</view>
</view> </view>
</view> </view>
</view> </view>

11
utils/request.js

@ -1,6 +1,6 @@
import functions from '@/utils/functions.js' import functions from '@/utils/functions.js'
import {host} from "@/config/host"; import {host} from "@/config/host";
const service = (params) => { const service = (params,showToast = true) => {
return new Promise((relove, reject) => { return new Promise((relove, reject) => {
let token=uni.getStorageSync('token') let token=uni.getStorageSync('token')
let user=uni.getStorageSync('user') let user=uni.getStorageSync('user')
@ -32,14 +32,19 @@ const service = (params) => {
reject(data); reject(data);
break; break;
case 202: case 202:
functions.error(data.msg); if(showToast){
functions.error(data.msg);
}
reject(data); reject(data);
break; break;
default: default:
relove(data); relove(data);
} }
} else { } else {
functions.error('连接服务器失败') if(showToast){
functions.error('连接服务器失败')
}
reject();
} }
}) })

Loading…
Cancel
Save