ソースを参照

赠送接口

master
ljc 5年前
コミット
5a3a212d3c
21個のファイルの変更456行の追加54行の削除
  1. +3
    -1
      laomenkuang_project/app.js
  2. +2
    -2
      laomenkuang_project/app.json
  3. +5
    -9
      laomenkuang_project/pages/TicketDetails/TicketDetails.js
  4. +5
    -2
      laomenkuang_project/pages/TicketDetails/TicketDetails.wxml
  5. +7
    -3
      laomenkuang_project/pages/TicketDetails/TicketDetails.wxss
  6. +5
    -5
      laomenkuang_project/pages/buyTicket/buyTicket.js
  7. +34
    -7
      laomenkuang_project/pages/givePage/givePage.js
  8. +4
    -2
      laomenkuang_project/pages/givePage/givePage.wxml
  9. +12
    -0
      laomenkuang_project/pages/givePage/givePage.wxss
  10. バイナリ
      laomenkuang_project/pages/images/getBg.png
  11. バイナリ
      laomenkuang_project/pages/images/getTicket.png
  12. バイナリ
      laomenkuang_project/pages/images/sureTicket.png
  13. +15
    -13
      laomenkuang_project/pages/personalCenter/personalCenter.js
  14. +4
    -4
      laomenkuang_project/pages/personalCenter/personalCenter.wxml
  15. +4
    -3
      laomenkuang_project/pages/personalCenter/personalCenter.wxss
  16. +152
    -0
      laomenkuang_project/pages/receiveTicket/receiveTicket.js
  17. +4
    -0
      laomenkuang_project/pages/receiveTicket/receiveTicket.json
  18. +35
    -0
      laomenkuang_project/pages/receiveTicket/receiveTicket.wxml
  19. +149
    -0
      laomenkuang_project/pages/receiveTicket/receiveTicket.wxss
  20. +9
    -3
      laomenkuang_project/pages/register/register.js
  21. +7
    -0
      laomenkuang_project/project.config.json

+ 3
- 1
laomenkuang_project/app.js ファイルの表示

@@ -6,7 +6,7 @@ App({
// logs.unshift(Date.now())
// wx.setStorageSync('logs', logs)
var openid = wx.getStorageSync('openid') || "";
console.log(this.globalData.present_id)
// 登录
if (!openid){
wx.login({
@@ -90,6 +90,8 @@ App({
},
globalData: {
userInfo: null,
present_id:"",//判断用户是通过领取优惠券进来的还是直接进的
number:"",//赠送优惠券的数量
openId:"",
session_key:"",
token:"",

+ 2
- 2
laomenkuang_project/app.json ファイルの表示

@@ -6,7 +6,8 @@
"pages/personalCenter/personalCenter",
"pages/buyTicket/buyTicket",
"pages/TicketDetails/TicketDetails",
"pages/givePage/givePage"
"pages/givePage/givePage",
"pages/receiveTicket/receiveTicket"
],
"window":{
"backgroundTextStyle": "light",
@@ -14,7 +15,6 @@
"navigationBarTitleText": "老门框优惠券售卖系统",
"navigationBarTextStyle": "black"
},
"style": "v2",
"sitemapLocation": "sitemap.json",
"tabBar":{
"color": "#666666",

+ 5
- 9
laomenkuang_project/pages/TicketDetails/TicketDetails.js ファイルの表示

@@ -15,19 +15,15 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var dataArr = JSON.parse(options.dataArr);
console.log(dataArr)
this.setData({
ticketUser: dataArr
})
this.ticketState(this.data.ticketUser.coupon_sell_id);
console.log(options.id)
this.getTicketUser(options.id,1)
},
ticketState:function(id){//优惠券使用状态
app.wxRequest(app.globalData.httpUrl + 'couponbuy/uniquehistory/'+id, {}, e => {
getTicketUser: function (id,from) {//获取优惠券信息
app.wxRequest(app.globalData.httpUrl + 'couponsell/detail', { coupon_sell_id: id, from: from}, e => {
console.log(e)
if (e.code == 200) {
this.setData({
ticketStateArr:e.data
ticketUser: e.data
})
}
}, this)

+ 5
- 2
laomenkuang_project/pages/TicketDetails/TicketDetails.wxml ファイルの表示

@@ -40,7 +40,10 @@
</view>
</view>

<scroll-view class="scrollY" scroll-y="true">
<view class="lookView">
<button plain="true" size="mini" class="lookCode">点击查看二维码</button>
</view>
<!-- <scroll-view class="scrollY" scroll-y="true">
<view class="history" wx:for="{{ticketStateArr}}">
<view class="historyLeft">
<image class="historyTicketBg" src="../images/historyTicketBg.png"></image>
@@ -51,5 +54,5 @@
<view class="tickType" wx:if="{{item.coupon_state==2}}">已使用</view>
<view class="tickType" wx:if="{{item.coupon_state==3}}">锁定</view>
</view>
</scroll-view>
</scroll-view> -->
</view>

+ 7
- 3
laomenkuang_project/pages/TicketDetails/TicketDetails.wxss ファイルの表示

@@ -87,8 +87,12 @@
width: 613rpx;
margin-left: 69rpx;
}

.scrollY{
.lookView{
width: 100%;
text-align: center;
margin-top: 100rpx;
}
/* .scrollY{
height: 200rpx;
margin-top: 107rpx;
}
@@ -135,4 +139,4 @@
font-family:SourceHanSansCN;
font-weight:bold;
color:rgba(235,97,0,1);
}
} */

+ 5
- 5
laomenkuang_project/pages/buyTicket/buyTicket.js ファイルの表示

@@ -19,11 +19,11 @@ Page({
*/
onLoad: function (options) {
console.log(options)
this.getTicketUser(options.index)
this.getTicketUser(options.index,1)
},

getTicketUser:function(index){//获取优惠券信息
app.wxRequest(app.globalData.httpUrl + 'couponsell/detail/' + index, {}, e => {
getTicketUser:function(index,from){//获取优惠券信息
app.wxRequest(app.globalData.httpUrl + 'couponsell/detail', { coupon_sell_id: index, from: from}, e => {
console.log(e)
if (e.code == 200) {
this.setData({
@@ -81,12 +81,12 @@ Page({

},
addFn:function(){
if (this.data.num<5){
// if (this.data.num<5){
this.data.num++;
this.setData({
buyNumber: this.data.num
})
}
// }
},
subtractFn:function(){
if (this.data.num > 1) {

+ 34
- 7
laomenkuang_project/pages/givePage/givePage.js ファイルの表示

@@ -1,4 +1,5 @@
// pages/givePage/givePage.js
const app = getApp()
Page({

/**
@@ -8,17 +9,32 @@ Page({
buyNumber: 1,
ticketNum: 1,
ticketUser: [],//优惠券信息
getBackData:"",//赠送回传字段
surplusNum:0,//剩余张数
yesMask:false,//提示赠送弹框
shareId:"",//获取用户标识
sellId:"",//优惠券券码
},

/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var dataArr = JSON.parse(options.dataArr);
console.log(dataArr)
this.setData({
ticketUser: dataArr
})
console.log(options.id)
this.data.sellId = options.id;
this.getTicketUser(options.id,2)
},
getTicketUser: function (id, from) {//获取优惠券信息
app.wxRequest(app.globalData.httpUrl + 'couponsell/detail', { coupon_sell_id: id, from: from }, e => {
console.log(e)
if (e.code == 200) {
this.setData({
ticketUser: e.data,
surplusNum:e.data.num,
shareId: e.data.present_id
})
}
}, this)
},

/**
@@ -66,8 +82,19 @@ Page({
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {

onShareAppMessage: function (options) {
var shareUrl = "";//分享指定路径
if (options.from === "button"){
shareUrl = '/pages/receiveTicket/receiveTicket?shareId=' + this.data.shareId + "&number=" + this.data.buyNumber
}
return{
title:"赠送给好友",
imageUrl: this.data.ticketUser.coupon_img_small,
path: shareUrl,
success: res=> {
console.log(res, "转发成功")
},
}
},
addFn: function () {
if (this.data.ticketNum < this.data.ticketUser.num) {

+ 4
- 2
laomenkuang_project/pages/givePage/givePage.wxml ファイルの表示

@@ -10,7 +10,7 @@
<view class="line"></view>
<view class="lineRig">
<text class="surplus">剩余</text>
<text class="bigWord">{{ticketUser.num}}</text>
<text class="bigWord">{{surplusNum}}</text>
<text class="smaWord">张</text>
</view>
</view>
@@ -51,5 +51,7 @@
</view>
</view>

<image class="giveBtn" src="../images/giveBtn.jpg"></image>
<button class="shareBtn" open-type = "share">
<image class="giveBtn" src="../images/giveBtn.jpg"></image>
</button>
</view>

+ 12
- 0
laomenkuang_project/pages/givePage/givePage.wxss ファイルの表示

@@ -1,4 +1,10 @@
/* pages/givePage/givePage.wxss */
page{
height: 100%;
}
.all{
height: 100%;
}
.ticketImg{
width: 100%;
height: 472rpx;
@@ -147,5 +153,11 @@
.giveBtn{
width: 100%;
height: 98rpx;
}
.shareBtn{
width: 100%;
height: 98rpx;
margin-top: 12rpx;
padding: 0;
border-radius: 0;
}

バイナリ
laomenkuang_project/pages/images/getBg.png ファイルの表示

変更前 変更後
幅: 700  |  高さ: 846  |  サイズ: 43KB

バイナリ
laomenkuang_project/pages/images/getTicket.png ファイルの表示

変更前 変更後
幅: 670  |  高さ: 98  |  サイズ: 9.0KB

バイナリ
laomenkuang_project/pages/images/sureTicket.png ファイルの表示

変更前 変更後
幅: 670  |  高さ: 98  |  サイズ: 8.1KB

+ 15
- 13
laomenkuang_project/pages/personalCenter/personalCenter.js ファイルの表示

@@ -14,7 +14,13 @@ Page({
mydeg: -90,
historydeg: -90,
historyArr: [],//优惠券使用记录列表
myTicketArr: [],//我的优惠券列表
myTicketArr: [
// { "coupon_img_small": "../images/smallTicket.jpg", "coupon_sell_id": 1, "coupon_name": "哈哈哈", "coupon_memo": "嘻嘻嘻","end_date":"2020/3/5"},
// { "coupon_img_small": "../images/smallTicket.jpg", "coupon_sell_id": 1, "coupon_name": "哈哈哈", "coupon_memo": "嘻嘻嘻", "end_date": "2020/3/5" },
// { "coupon_img_small": "../images/smallTicket.jpg", "coupon_sell_id": 1, "coupon_name": "哈哈哈", "coupon_memo": "嘻嘻嘻", "end_date": "2020/3/5" },
// { "coupon_img_small": "../images/smallTicket.jpg", "coupon_sell_id": 1, "coupon_name": "哈哈哈", "coupon_memo": "嘻嘻嘻", "end_date": "2020/3/5" },
// { "coupon_img_small": "../images/smallTicket.jpg", "coupon_sell_id": 1, "coupon_name": "哈哈哈", "coupon_memo": "嘻嘻嘻", "end_date": "2020/3/5" },
],//我的优惠券列表
},

/**
@@ -25,7 +31,7 @@ Page({
this.historyTicket();
},
myTicket:function(){//获取我的优惠券列表
app.wxRequest(app.globalData.httpUrl + 'couponbuy/buytype', {}, e => {
app.wxRequest(app.globalData.httpUrl + 'couponbuy/validtype', {}, e => {
console.log(e)
if (e.code == 200) {
this.setData({
@@ -44,6 +50,9 @@ Page({
}
}, this)
},
lower:function(){//检测上拉是否到底
console.log("到底了")
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
@@ -122,22 +131,15 @@ Page({
},
lookTicket: function (e) {//查看优惠券
console.log(e)
console.log(this.data.myTicketArr)
var index = e.currentTarget.dataset.index;
var dataArr = this.data.myTicketArr[index];
dataArr = JSON.stringify(dataArr);
console.log(dataArr)
var id = e.currentTarget.dataset.id;
wx.navigateTo({
url: '../TicketDetails/TicketDetails?dataArr=' + dataArr,
url: '../TicketDetails/TicketDetails?id=' + id,
})
},
giveTicket:function(e){//赠送优惠券
var index = e.target.dataset.index;
var dataArr = this.data.myTicketArr[index];
dataArr = JSON.stringify(dataArr);
console.log(dataArr)
var id = e.target.dataset.id;
wx.navigateTo({
url: '../givePage/givePage?dataArr=' + dataArr,
url: '../givePage/givePage?id=' + id,
})
},
getUser:function(e){//点击登陆获取用户信息

+ 4
- 4
laomenkuang_project/pages/personalCenter/personalCenter.wxml ファイルの表示

@@ -19,9 +19,9 @@
<image style="transform:rotate({{mydeg}}deg)" class="ticketArrows" src="../images/ticketArrows.png"></image>
</view>

<scroll-view class="scrollY1" scroll-y="true" wx:if="{{myTicketArrows}}">
<scroll-view class="scrollY1" scroll-y="true" wx:if="{{myTicketArrows}}" bindscrolltolower="lower">
<view class="contAll" wx:for="{{myTicketArr}}">
<view class="ticketCont">
<view class="ticketCont" bindtap="lookTicket" data-id = "{{item.coupon_sell_id}}">
<view class="ticketImg">
<image class="ticketImg" src="{{item.coupon_img_small}}"></image>
</view>
@@ -32,8 +32,8 @@
</view>
</view>
<view class="look">
<view bindtap="lookTicket" data-index = "{{index}}" class="clickLook">点击查看券码</view>
<image bindtap="giveTicket" class="giveFrinedBtn" data-index = "{{index}}" src="../images/giveFrinedBtn.png"></image>
<!-- <view bindtap="lookTicket" data-index = "{{index}}" class="clickLook">点击查看券码</view> -->
<image bindtap="giveTicket" class="giveFrinedBtn" data-id = "{{item.coupon_sell_id}}" src="../images/giveFrinedBtn.png"></image>
</view>
</view>
</scroll-view>

+ 4
- 3
laomenkuang_project/pages/personalCenter/personalCenter.wxss ファイルの表示

@@ -101,15 +101,16 @@
color:rgba(153,153,153,1);
}
.look{
display: flex;
/* display: flex;
justify-content: space-between;
align-items: center;
align-items: center;*/
margin-top: 41rpx;
margin-bottom: 33rpx;
margin-bottom: 33rpx;
}
.giveFrinedBtn{
width: 240rpx;
height: 64rpx;
float: right;
}
.clickLook{
font-size:30rpx;

+ 152
- 0
laomenkuang_project/pages/receiveTicket/receiveTicket.js ファイルの表示

@@ -0,0 +1,152 @@
// pages/receiveTicket/receiveTicket.js
const app = getApp();
Page({

/**
* 页面的初始数据
*/
data: {
yesGet: true,//是否被领取
ticketUser:[],//优惠券信息
titleWord:"",
presentId:"",//接受的id
},

/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
app.globalData.present_id = options.shareId;
this.data.presentId = options.shareId;
app.globalData.number = options.number;
this.getTicketUser(options.shareId, options.number);
// wx.showToast({
// title: options.number,
// duration:2000
// })
},

getTicketUser: function (id,number) {//获取优惠券信息
app.wxRequest(app.globalData.httpUrl + 'couponbuy/presentstate', { present_id: id, present_num: number }, e => {
console.log(e)
if (e.code == 201) {
this.setData({
ticketUser: e.data,
yesGet: true
})
} else if (e.code == 202){
this.setData({
yesGet: false,
titleWord:"此券已被领取"
})
} else if (e.code == 203){
this.setData({
yesGet: false,
titleWord: "此券已失效"
})
} else if (e.code == -201) {
this.setData({
yesGet: false,
titleWord: "没有相关赠送记录"
})
} else if (e.code == 204) {
this.setData({
yesGet: false,
titleWord: "赠送优惠券不足,无法领取"
})
} else if (e.code == 205) {
this.setData({
yesGet: false,
titleWord: "优惠券超限,无法领取"
})
}
}, this)
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {

},

/**
* 生命周期函数--监听页面显示
*/
onShow: function () {

},

/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {

},

/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {

},

/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {

},

/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {

},

/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {

},
// "p1583395285z86"
getTicketFn:function(){//点击领取优惠券
var id = this.data.presentId;
app.wxRequest(app.globalData.httpUrl + 'couponbuy/receive', { present_id: id }, e => {
console.log(e)
if (e.code == 200) {
wx.showToast({
title: '领取成功',
duration:500
})
setTimeout(()=>{
wx.switchTab({
url: '/pages/index/index'
})
},500)
} else if (e.code == -201) {//用户未注册
console.log(e.message)
} else if (e.code == -202) {//没有相应赠品记录
console.log(e.message)
}else if (e.code == -203){//无法领取自己的优惠券
console.log(e.message)
wx.showToast({
title: '领取失败',
duration: 500
})
} else if (e.code == -204) {//赠送优惠券已领取
console.log(e.message)
} else if (e.code == -205) {//优惠券已失效
console.log(e.message)
wx.showToast({
title: '优惠券已失效',
duration: 500
})
}
}, this,"POST")
},
backIndex:function(){//优惠券已被领取,点击确定返回首页

},
})

+ 4
- 0
laomenkuang_project/pages/receiveTicket/receiveTicket.json ファイルの表示

@@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarTitleText": "领取优惠券"
}

+ 35
- 0
laomenkuang_project/pages/receiveTicket/receiveTicket.wxml ファイルの表示

@@ -0,0 +1,35 @@
<!--pages/receiveTicket/receiveTicket.wxml-->

<image class="getBg" src="../images/getBg.png"></image>
<view class="all" wx:if="{{yesGet}}">
<view class="content">
<view class="userName">你的好友{{ticketUser.nickname}}</view>
<view class="userPhone">{{ticketUser.user_phone}}</view>
<view class="giveTo">赠送给您</view>
<view class="giveNum">
<text class="textNum">{{ticketUser.count}}</text>
<text class="text">张</text>
</view>
<view class="ticketType">{{ticketUser.coupon_type}}</view>
<view class="line"></view>
</view>
<view class="contBot">
<view class="picView">
<image class="smallTicket" src="{{ticketUser.coupon_img_small}}"></image>
</view>
<view class="textView">
<text class="nameText">{{ticketUser.coupon_name}}</text>
<text class="timeText">{{ticketUser.coupon_memo}}</text>
<text class="timeText">(有效期:{{ticketUser.end_date}})</text>
</view>
</view>
<image bindtap="getTicketFn" class="getTicket" src="../images/getTicket.png"></image>
</view>

<view wx:if="{{!yesGet}}">
<view class="ticketState">{{titleWord}}</view>
<view class="question">如有疑问请联系</view>
<view class="wx">{{ticketUser.nickname}}</view>
<view class="phone">{{ticketUser.user_phone}}</view>
<image bindtap="backIndex" class="sureTicket" src="../images/sureTicket.png"></image>
</view>

+ 149
- 0
laomenkuang_project/pages/receiveTicket/receiveTicket.wxss ファイルの表示

@@ -0,0 +1,149 @@
/* pages/receiveTicket/receiveTicket.wxss */
page{
height:100%;
position: fixed;
}
.all{
width: 100%;
height:100%;
}
.getBg{
width: 700rpx;
height: 846rpx;
position: absolute;
left: 50%;
top: 10%;
transform: translateX(-50%);
z-index: 9;
}
.userName{
text-align: center;
font-size:40rpx;
font-family:SourceHanSansCN;
font-weight:500;
color:rgba(0,0,0,1);
}
.userPhone{
text-align: center;
font-size:24rpx;
font-family:SourceHanSansCN;
font-weight:500;
color:rgba(153,153,153,1);
margin-top: 10rpx;
margin-bottom: 20rpx;
}
.giveTo{
text-align: center;
font-size:30rpx;
font-family:SourceHanSansCN;
font-weight:bold;
color:rgba(0,0,0,1);
}
.giveNum{
text-align: center;
}
.ticketType{
text-align: center;
font-size:40rpx;
font-family:SourceHanSansCN;
font-weight:500;
color:rgba(51,51,51,1);
}
.textNum{
font-size:80rpx;
font-family:DINPro;
font-weight:500;
color:rgba(235,97,0,1);
}
.text{
font-size:30rpx;
font-family:SourceHanSansCN;
font-weight:500;
color:rgba(51,51,51,1);
}
.content{
margin-top: 220rpx;
}

.picView{
width: 248rpx;
height: 248rpx;
border-radius: 10rpx;
overflow: hidden;
}
.smallTicket{
width: 248rpx;
height: 248rpx;
}
.contBot{
display: flex;
justify-content: center;
align-items: center;
margin-top: 80rpx;
}
.textView{
width: 318rpx;
height: 248rpx;
padding-left: 33rpx;
}
.textView text{
display: block;
}
.nameText{
font-size:60rpx;
font-family:DINPro;
font-weight:bold;
color:rgba(106,10,14,1);
margin-top: 42rpx;
margin-bottom: 25rpx
}
.timeText{
font-size:20rpx;
font-family:SourceHanSansCN;
font-weight:300;
color:rgba(153,153,153,1);
}
.getTicket{
display: block;
width: 670rpx;
height: 98rpx;
margin: 180rpx auto 0 auto;
}


.ticketState{
margin-top: 380rpx;
margin-bottom: 203rpx;
text-align: center;
font-size:60rpx;
font-family:SourceHanSansCN;
font-weight:500;
color:rgba(0,0,0,1);
}
.question{
text-align: center;
font-size:30rpx;
font-family:SourceHanSansCN;
font-weight:500;
color:rgba(102,102,102,1);
}
.wx{
text-align: center;
font-size:24rpx;
font-family:SourceHanSansCN;
font-weight:500;
color:rgba(153,153,153,1);
}
.phone{
text-align: center;
font-size:30rpx;
font-family:SourceHanSansCN;
font-weight:500;
color:rgba(102,102,102,1);
}
.sureTicket{
display: block;
width: 670rpx;
height: 98rpx;
margin: 310rpx auto 0 auto;
}

+ 9
- 3
laomenkuang_project/pages/register/register.js ファイルの表示

@@ -133,9 +133,15 @@ Page({
duration: 500
})
setTimeout(function () {
wx.switchTab({
url: '../index/index'
})
if (app.globalData.present_id){
wx.switchTab({
url: '/pages/receiveTicket/receiveTicket?shareId=' + app.globalData.present_id + "&number=" + app.globalData.number
})
} else {
wx.switchTab({
url: '../index/index'
})
}
}, 1000)
}
}, this,"POST")

+ 7
- 0
laomenkuang_project/project.config.json ファイルの表示

@@ -98,6 +98,13 @@
"pathName": "pages/register/register",
"query": "",
"scene": null
},
{
"id": 0,
"name": "领取优惠券",
"pathName": "pages/receiveTicket/receiveTicket",
"query": "",
"scene": null
}
]
}

読み込み中…
キャンセル
保存