瀏覽代碼

更新

master
wuwenjie 5 年之前
父節點
當前提交
da63b887be
共有 13 個文件被更改,包括 285 次插入69 次删除
  1. +30
    -15
      app.js
  2. +5
    -0
      app.json
  3. +1
    -0
      libs/amap-wx.js
  4. +37
    -16
      pages/coupon/coupon.js
  5. +10
    -8
      pages/coupon/coupon.wxml
  6. +27
    -4
      pages/login/login.js
  7. +12
    -1
      pages/login/login.wxml
  8. +60
    -4
      pages/login/login.wxss
  9. +1
    -0
      pages/record/record.js
  10. +1
    -1
      pages/record/record.wxss
  11. +97
    -18
      pages/store/store.js
  12. +4
    -2
      pages/store/store.wxml
  13. 二進制
      static/coupon/Coupon1.png

+ 30
- 15
app.js 查看文件

@@ -63,22 +63,37 @@ App({
return userInfo
},
getInfo: function() {
this.requestGet('getinfo', "", res => {
if (res.code == 200) {
this.globalData.userState = 1;
this.globalData.storeData=res.data;
if (res.data.user_info){
res.data.user_info.nickName = res.data.user_info.nickname
res.data.user_info.avatarUrl = res.data.user_info.headimgurl
}
this.globalData.userInfo = res.data.user_info;
} else {
this.globalData.userState = 0;
}
var accountInfo = wx.getStorageSync('laomenkuangAccountInfo');
if (accountInfo){//已有账户信息-已登录
this.globalData.userState = 1;
this.globalData.storeData = accountInfo;
if (this.userStateReadyCallback) {
this.userStateReadyCallback(this.globalData.userState)
this.userStateReadyCallback(1)
}
})
var userInfo = wx.getStorageSync('laomenkuangUserInfo');
if (userInfo){
this.globalData.userInfo = userInfo;
}
}else{
this.requestGet('getinfo', "", res => {
if (res.code == 200) {
this.globalData.userState = 1;
wx.setStorageSync('laomenkuangAccountInfo', res.data);//老门框账户信息-id
this.globalData.storeData = res.data;
if (res.data.user_info) {
res.data.user_info.nickName = res.data.user_info.nickname
res.data.user_info.avatarUrl = res.data.user_info.headimgurl
}
wx.setStorageSync('laomenkuangUserInfo', res.data.user_info);//老门框用户信息-头像昵称
this.globalData.userInfo = res.data.user_info;
} else {
this.globalData.userState = 0;
}
if (this.userStateReadyCallback) {
this.userStateReadyCallback(this.globalData.userState)
}
})
}
},
requestGet: function(url, data, callBack) {
wx.request({
@@ -111,7 +126,7 @@ App({
},
globalData: {
userInfo: null,
userState: -1, //-1未获取 -0未注册 1已注册
userState: -1, //-1未获取 0未注册 1已注册
storeData:null,//店铺信息
apiUrl: 'https://laomenkuang.jiyou-tech.com/apiWxAdmin/',
baseInfo: null,

+ 5
- 0
app.json 查看文件

@@ -6,6 +6,11 @@
"pages/record/record",
"pages/home/home"
],
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序定位离你最近的门店"
}
},
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",

+ 1
- 0
libs/amap-wx.js
文件差異過大導致無法顯示
查看文件


+ 37
- 16
pages/coupon/coupon.js 查看文件

@@ -9,28 +9,22 @@ Page({
type: 2, //1券码核销 2手机号核销
user_phone: '', //手机号
state: 0, //0核销未完成 1核销中 2核销已完成
headImgUrl:'',//头图
totalNums: 1, //总数量
nums: 1, //核销数量
coupon_name: '', //优惠券名称
couponTime: '', //优惠券购买时间
code_num: '', //核销短信验证码
couponCode: '', //券号
couponType: '', //券类型
duration: '', //券期间
type_name:'',//券类型
},
/**
* 核销数修改
*/
changeNums(event) {
var nums
if (event.detail.value > this.data.totalNums) {
nums = this.data.totalNums
}
if (event.detail.value < 1) {
nums = 1
}
this.setData({
nums: nums
nums: parseInt(event.detail.value)
})
},
/**
@@ -48,6 +42,14 @@ Page({
if (this.data.state == 1) {
return
}
if (this.data.nums>this.data.totalNums){
wx.showToast({
title: '券剩余数量不足',
icon: 'none',
duration: 2000
})
return
}
var data;
if (this.data.type == 1) { //券核销
data = {
@@ -83,8 +85,8 @@ Page({
if (res.code == 200) {
state = 2;
if (that.data.type == 2) { //手机号核销
wx.switchTab({
url: '../record/record'
this.setData({
totalNums: this.data.totalNums-this.data.nums
})
}
} else {
@@ -104,7 +106,11 @@ Page({
* 添加优惠券
*/
addCoupon() {
if (this.data.nums + 1 <= this.data.totalNums) {
if (isNaN(this.data.nums)) {
this.setData({
nums: 1
})
}else if (this.data.nums + 1 <= this.data.totalNums) {
this.setData({
nums: this.data.nums + 1
})
@@ -114,12 +120,23 @@ Page({
* 减少优惠券
*/
reduceCoupon() {
if (this.data.nums - 1 > 0) {
if (isNaN(this.data.nums)){
this.setData({
nums: 1
})
}else if (this.data.nums - 1 > 0) {
this.setData({
nums: this.data.nums - 1
})
}
},
blueNums(){
if (isNaN(this.data.nums)) {
this.setData({
nums: 1
})
}
},
/**
* 返回核销大厅
*/
@@ -142,9 +159,10 @@ Page({
type: 1,
couponCode: code,
coupon_name: couponData.coupon_name,
type_name: couponData.type_name,
couponTime: couponData.buy_date,
couponType: couponData.coupon_type,
duration: couponData.duration
duration: couponData.duration,
headImgUrl: couponData.coupon_img_large
})
}
if (pohone) { //手机号查询
@@ -153,7 +171,10 @@ Page({
user_phone: pohone,
totalNums: couponData.num,
coupon_name: couponData.coupon_name,
couponTime: couponData.buy_date
type_name: couponData.type_name,
couponTime: couponData.buy_date,
duration: couponData.duration,
headImgUrl: couponData.coupon_img_large
})
/**
* 发送验证码

+ 10
- 8
pages/coupon/coupon.wxml 查看文件

@@ -1,11 +1,11 @@
<!--pages/coupon/coupon.wxml-->
<view class="container" style="background-color:#f6f6f6;">
<image class="couponImg" src="../../static/coupon/Coupon1.png"></image>
<image class="couponImg" src="{{headImgUrl}}" mode='aspectFill'></image>
<view class="detailsBox shadow">
<image class="bottomBg" src="../../static/coupon/bottomBg1.png"></image>
<image class="decorate" src="../../static/coupon/01.png"></image>
<view class="detailsInfo">
<text class="txt1">{{coupon_name}}</text>
<text class="txt1">{{coupon_name+type_name}}</text>
<text class="txt2">购买时间:{{couponTime}}</text>
</view>
<view class="detailsRight" wx:if="{{type==2}}"><image class="txt" src="../../static/coupon/txt.png"></image>{{totalNums}}<text class="company">张</text>
@@ -18,17 +18,19 @@
<text class="number">券码:{{couponCode}}</text>
<view class="txt">此券有效</view>
</view>
<view id="couponDetails" class="relative clearfix" wx:if="{{type==1&&state==2}}">
<view id="couponDetails" class="relative clearfix" wx:if="{{state==2}}">
<view class="title">核销详情</view>
<view class="detailsItem">
<view class="sign"></view>
<text class="itemTitle">券码</text>
<text class="itemContent">{{couponCode}}</text>
<text class="itemTitle" wx:if="{{type==1}}">券码</text>
<text class="itemTitle" wx:else>数量</text>
<text class="itemContent" wx:if="{{type==1}}">{{couponCode}}</text>
<text class="itemContent" wx:else>{{nums}}</text>
</view>
<view class="detailsItem">
<view class="sign"></view>
<text class="itemTitle">类型</text>
<text class="itemContent">{{couponType}}</text>
<text class="itemContent">{{coupon_name+type_name}}</text>
</view>
<view class="detailsItem">
<view class="sign"></view>
@@ -37,12 +39,12 @@
</view>
<view class="state">核销成功</view>
</view>
<view id="vCodeBox" wx:if="{{type==2}}">
<view id="vCodeBox" wx:if="{{type==2&&state!=2}}">
<input placeholder="输入短信验证码" placeholder-style="color:#FFFFFF;font-size:30rpx;" value="{{code_num}}" bindinput="changeCode"></input>
<view class="countBox">
<text>核销</text>
<view class="countContent">
<input type="number" value="{{nums}}" bindinput="changeNums"></input>
<input type="number" value="{{nums}}" bindinput="changeNums" bindblur='blueNums'></input>
<image class="symbolBox" src="../../static/coupon/symbolLeft.png" style="left:-5rpx;" bindtap="reduceCoupon"></image>
<image class="symbolBox" src="../../static/coupon/symbolRight.png" style="right:-5rpx;" bindtap="addCoupon"></image>
</view>

+ 27
- 4
pages/login/login.js 查看文件

@@ -10,6 +10,12 @@ Page({
isLoginIng: false,
canIUse: wx.canIUse('button.open-type.getUserInfo'),
hasUserInfo: false,
showTip:true,
},
hiddenTip(){
this.setData({
showTip:false
})
},
/**
* 登录
@@ -39,6 +45,7 @@ Page({
}
},
login(data) {
var that=this
var data={
account_id: data.userName,
account_password: data.password
@@ -48,10 +55,15 @@ Page({
isLoginIng: false
})
if(res.code==200){
wx.setStorageSync('laomenkuangAccountInfo', res.data);//老门框账户信息
app.globalData.storeData = res.data;
wx.switchTab({
url: '../home/home'
})
app.globalData.userState = 1
console.log('回复登录信息')
if (that.data.hasUserInfo){
wx.switchTab({
url: '../home/home'
})
}
}else{
wx.showToast({
title: res.message,
@@ -95,7 +107,7 @@ Page({
wx.switchTab({
url: '../home/home'
})
} else if (app.globalData.userState == -1){
} else if (app.globalData.userState == -1){//等待结果
app.userStateReadyCallback = res => {
if(res){
wx.switchTab({
@@ -107,6 +119,10 @@ Page({
})
}
}
} else{//未注册
that.setData({
showLogin: true
})
}
},
/**
@@ -118,11 +134,18 @@ Page({
hasUserInfo: true
})
if (e.detail.userInfo){
wx.setStorageSync('laomenkuangUserInfo', e.detail.userInfo);//老门框用户信息-头像昵称
var userInfo = app.setUserInfo(e.detail.userInfo)
app.requestPost('submit', userInfo,res=>{
console.log(res)
})
}
console.log('回复授权信息')
if (app.globalData.userState == 1) {
wx.switchTab({
url: '../home/home'
})
}
},

/**

+ 12
- 1
pages/login/login.wxml 查看文件

@@ -12,8 +12,19 @@
密码
<input name="password" password></input>
</view>
<button wx:if="{{!hasUserInfo && canIUse}}" class="btn" open-type="getUserInfo" bindgetuserinfo="getUserInfo" >登录</button>
<button wx:if="{{!hasUserInfo && canIUse}}" class="btn {{isLoginIng?'select':''}}" form-type="submit" open-type="getUserInfo" bindgetuserinfo="getUserInfo">登录</button>
<button wx:else class="btn {{isLoginIng?'select':''}}" form-type="submit">登录</button>
<view class="tipBox">
<view class="title">温馨提示</view>
<view class="content">本小程序仅限内部人员使用,各门店工作人员首次使用需使用专属帐号密码登陆。</view>
</view>
</form>
</view>
<view class="mask" wx:if="{{showTip}}">
<view class="tipBox">
<view class="header">温馨提示</view>
<view class="contentTxt">本小程序仅限内部人员使用,各门店工作人员首次使用需使用专属帐号密码登陆。</view>
<button bindtap="hiddenTip">确定</button>
</view>
</view>
</view>

+ 60
- 4
pages/login/login.wxss 查看文件

@@ -43,12 +43,68 @@
height: 98rpx;
line-height: 98rpx;
border-radius: 49rpx;
color: #ffffff;
color: #fff;
font-size: 36rpx;
text-align: center;
margin-top: 111rpx;
background: linear-gradient(-72deg, rgba(235, 97, 0, 1), rgba(255, 137, 42, 1));
}
.btn.select{
background: #cccccc;
}
.btn.select {
background: #ccc;
}
.fromBox .tipBox{
margin-top: 15rpx;
}
.fromBox .tipBox>.title{
color: #cccccc;
text-align: center;
font-size: 30rpx;
margin-bottom: 15rpx;
}
.fromBox .tipBox>.content{
color: #cccccc;
text-align: center;
font-size: 25rpx;
line-height: 45rpx;
}
.mask {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.7);
}
.mask>.tipBox {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 600rpx;
height: 550rpx;
background-color: #fff;
border-radius: 15rpx;
}
.mask>.tipBox>.header {
width: 100%;
height: 80rpx;
text-align: center;
line-height: 80rpx;
border-bottom: 2rpx solid #cccccc;
}
.mask>.tipBox>.contentTxt{
line-height: 75rpx;
margin: 30rpx 40rpx 0 40rpx;
}
.mask>.tipBox>button{
position: absolute;
width: 100%;
bottom: 0rpx;
color: #fffefe;
font-size: 36rpx;
background: linear-gradient(-72deg, rgba(235, 97, 0, 1), rgba(255, 137, 42, 1));
}

+ 1
- 0
pages/record/record.js 查看文件

@@ -66,6 +66,7 @@ Page({
getUserInfo: function (e) {
app.globalData.userInfo = e.detail.userInfo
if (e.detail.userInfo) {
wx.setStorageSync('laomenkuangUserInfo', e.detail.userInfo);//老门框用户信息-头像昵称
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true

+ 1
- 1
pages/record/record.wxss 查看文件

@@ -89,7 +89,7 @@
}
.item>.details>.infoBox{
color: #999999;
font-size: 23rpx;
font-size: 21rpx;
display: flex;
justify-content: space-between;
margin-top: 5rpx;

+ 97
- 18
pages/store/store.js 查看文件

@@ -1,5 +1,6 @@
// pages/store/store.js
const app = getApp()
var amapFile = require('../../libs/amap-wx.js');
Page({

/**
@@ -18,15 +19,19 @@ Page({
multiIndex: [0, 0], //省份下标
multiData: null, //省份数据
cur_page: 1, //当前页数
show_num: 99, //每页显示项目数
show_num: 10, //每页显示项目数
storeList: [], //门店列表
state: 0, //0未获取 1获取中 2无更多
addressData: null, //地址信息
locationData: null, //经纬度信息
},
/**
* 清除搜索内容
*/
clearSearchContent() {
this.setData({
key: ""
key: "",
cur_page: 1
})
this.search()
},
@@ -58,7 +63,7 @@ Page({
/**
* 打开定位地图
*/
openLocation(e){
openLocation(e) {
var latitude = parseFloat(e.currentTarget.dataset.latitude);
var longitude = parseFloat(e.currentTarget.dataset.longitude);
var shopName = e.currentTarget.dataset.name;
@@ -70,25 +75,67 @@ Page({
})
},
/**
* 获取当前城市
*/
getCurrentCity() {
var that = this
var myAmapFun = new amapFile.AMapWX({
key: 'b61cd7baf9244dd531eb27d227218a34'
});
myAmapFun.getRegeo({
success: function(res) {
//成功回调
that.setData({
addressData: res[0].regeocodeData.addressComponent,
locationData: {
latitude: res[0].latitude,
longitude: res[0].longitude
}
})
console.log(res)
that.getProvince();
},
fail: function(info) {
//失败回调
that.getProvince();
}
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
wx.hideShareMenu();
//获取省份信息
this.getCurrentCity()
},
/**
* 获取省份信息
*/
getProvince() {
app.requestGet('shop/shop_province', '', res => {
if (res.code == 200) {
var city='全部';
for(var i=0;i<res.data.length;i++){
var city = '全部';
for (var i = 0; i < res.data.length; i++) {
city += "," + res.data[i].shop_city
}
var indexList = [0, 0]
if (this.data.addressData){
var cityList = city.split(',')
var cityIndex = cityList.indexOf(this.data.addressData.city)
if (cityIndex > 0) {
indexList[1] = cityIndex;
}
}

res.data.unshift({
shop_city:city,
shop_province:'全部'
shop_city: city,
shop_province: '全部'
})
this.setData({
multiData: res.data,
multiIndex: indexList
})
this.changeCityList(this.data.multiIndex, true);
this.changeCityList(indexList, true);
this.getStoreList();
}
})
@@ -126,7 +173,7 @@ Page({
bindMultiPickerChange(e) {
this.changeCityList(e.detail.value, true);
this.setData({
cur_page:1
cur_page: 1
})
this.getStoreList();
},
@@ -137,30 +184,62 @@ Page({
* 获取门店列表数据
*/
getStoreList() {
this.setData({
storeList: []
})
if (this.data.cur_page == 1) {
this.setData({
storeList: []
})
}
var city = this.data.showMultArray[1][this.data.multiIndex[1]] == '全部' ? '' : this.data.showMultArray[1][this.data.multiIndex[1]];
var data = {
'shop_city': city,
'key': this.data.key,
'cur_page': this.data.cur_page,
'show_num': this.data.show_num
'show_num': this.data.show_num,
"location": this.data.locationData ? 2 : 1,
"lng": this.data.locationData ? this.data.locationData.longitude : null,
"lat": this.data.locationData ? this.data.locationData.latitude : null,
}
app.requestGet('shop/search', data, res => {
app.requestGet('shop/shopsearch', data, res => {
if (res.code === 200) {
this.setData({
storeList: res.data
})
var newList = JSON.parse(JSON.stringify(this.data.storeList))
for (var i = 0; i < res.data.length; i++) {
newList.push(res.data[i])
}
if (res.data.length < this.data.show_num) {
this.setData({
storeList: newList,
state: 2
})
} else {
this.setData({
storeList: newList,
state: 0
})
}
} else {
wx.showToast({
title: res.message,
icon: 'none',
duration: 2000
})
this.setData({
state: 0
})
}
})
},
/**
* 滚动到底部
*/
scrollDown() {
if (this.data.state == 0) {
this.setData({
state: 1,
cur_page: this.data.cur_page + 1
})
this.getStoreList()
}
},

/**
* 生命周期函数--监听页面初次渲染完成

+ 4
- 2
pages/store/store.wxml 查看文件

@@ -14,7 +14,7 @@
</view>
<view class="btnSearch" bindtap="search">搜索</view>
</view>
<scroll-view class="content" scroll-y="true">
<scroll-view class="content" scroll-y="true" bindscrolltolower='scrollDown' lower-threshold='1500'>
<view class="Item clearfix" wx:for="{{storeList}}" wx:key="id">
<view class="photoBox">
<image class="photo" src="{{item.shop_img}}" mode="aspectFill"></image>
@@ -25,12 +25,14 @@
<view class="name">{{item.shop_name}}</view>
<view class="infoBox" data-name="{{item.shop_name}}" data-latitude="{{item.shop_latitude}}" data-longitude="{{item.shop_longtitude}}" bindtap="openLocation">
<image class="icon" src="../../static/store/location.png"></image>
<text>{{item.shop_addr}}</text>
<text style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">{{item.shop_addr}}</text>
</view>
<view class="infoBox" data-mobile="{{item.shop_phone}}" bindtap="callMobile">
<image class="icon" src="../../static/store/mobile.png"></image>
<text>{{item.shop_phone}}</text>
</view>
</view>
<view style="text-align: center;margin: 15rpx;" wx:if="{{state==2&&storeList.length>show_num}}">暂无更多</view>
<view style="text-align: center;margin: 15rpx;" wx:if="{{state==1}}">获取中....</view>
</scroll-view>
</view>

二進制
static/coupon/Coupon1.png 查看文件

Before After
Width: 750  |  Height: 300  |  Size: 86KB

Loading…
取消
儲存