Bladeren bron

feat: 添加优惠券详情

wkw 3 weken geleden
bovenliggende
commit
d181978dba

+ 19 - 0
api/other.js

@@ -31,6 +31,7 @@ export function storeList(params) {
     data: params
   });
 }
+// 获取门店详情
 export function storeDetail(store_id,params) {
   return request({
     url: `/api/store/${store_id}`,
@@ -38,5 +39,23 @@ export function storeDetail(store_id,params) {
     data: params
   });
 }
+// 发送短信
+export function smsSend(data) {
+  return request({
+    url: '/api/sms/send',
+    method: 'POST',
+    data
+  });
+}
+// 我的代金卷列表
+export function couponListApi(params) {
+  return request({
+    url: '/api/coupon/list',
+    method: 'GET',
+    data: params
+  });
+}
+
+
 
 

+ 8 - 0
api/user.js

@@ -28,3 +28,11 @@ export function userModify(data) {
     data
   });
 }
+// 上报用户行为
+export function behaviorReport(data) {
+  return request({
+    url: '/api/behavior/report',
+    method: 'POST',
+    data
+  });
+}

+ 2 - 1
app.json

@@ -8,7 +8,8 @@
     "pages/rules/rules",
     "pages/setting/setting",
     "pages/registrationRecords/registrationRecords",
-    "pages/coupon/coupon"
+    "pages/coupon/coupon",
+    "pages/couponDetail/couponDetail"
   ],
   "window": {
     "navigationBarTextStyle": "black",

+ 0 - 1
custom-tab-bar/index.js

@@ -40,7 +40,6 @@ Component({
     // 分享逻辑
     onShareAppMessage() {
       return {
-        title: '这里是分享标题',
         path: '/pages/index/index',
         imageUrl: '/static/tabbar/weixin.png'
       }

+ 59 - 55
pages/coupon/coupon.js

@@ -1,66 +1,70 @@
-// pages/coupon/coupon.js
+import { couponListApi } from '../../api/other';
 Page({
-
-  /**
-   * 页面的初始数据
-   */
   data: {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面加载
-   */
-  onLoad(options) {
-
+    couponList: [],
+    page: 1,
+    pageSize: 10,
+    loadingMore: false,
+    noMore: false,
+    refreshing: false
   },
 
-  /**
-   * 生命周期函数--监听页面初次渲染完成
-   */
-  onReady() {
-
+  onLoad() {
+    this.loadData(true);
   },
-
-  /**
-   * 生命周期函数--监听页面显示
-   */
-  onShow() {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面隐藏
-   */
-  onHide() {
-
+  async loadData(isRefresh = false) {
+    if (this.data.loadingMore) return;
+    let page = isRefresh ? 1 : this.data.page;
+    this.setData({ loadingMore: true });
+    try {
+      const res = await couponListApi({ page, pageSize: this.data.pageSize });
+
+      const statusImgMap = {
+        used: '/static/image/yhx.png',   // 已核销
+        unused: '/static/image/whx.png', // 未核销
+      };
+
+      const newList = res.data.list || [];
+      let allList = isRefresh ? newList : [...this.data.couponList, ...newList];
+      // allList = allList.map(item => ({
+      //   ...item,
+      //   typeText: item.type === 1 ? '菜品券' : '通用券',
+      //   statusImg: statusImgMap[item.status] || '/static/image/whx.png',
+      //   expireTime: item.expire_time || '--'
+      // }));
+
+      this.setData({
+        couponList: allList,
+        loadingMore: false,
+        page: page + 1,
+        noMore: allList.length >= res.data.total,
+        refreshing: false
+      });
+    } catch (err) {
+      console.error(err);
+      wx.showToast({ title: '加载失败', icon: 'none' });
+      this.setData({
+        loadingMore: false,
+        refreshing: false
+      });
+    }
   },
-
-  /**
-   * 生命周期函数--监听页面卸载
-   */
-  onUnload() {
-
+  // 上拉触底
+  onReachBottom() {
+    if (this.data.noMore) return;
+    this.loadData();
   },
 
-  /**
-   * 页面相关事件处理函数--监听用户下拉动作
-   */
+  // 下拉刷新
   onPullDownRefresh() {
-
-  },
-
-  /**
-   * 页面上拉触底事件的处理函数
-   */
-  onReachBottom() {
-
+    if (this.data.refreshing) return;
+    this.setData({ refreshing: true, noMore: false, page: 1 });
+    this.loadData(true);
   },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage() {
-
+  goPage(e) {
+    const coupon = e.currentTarget.dataset.item;
+    wx.navigateTo({
+      url: `/pages/coupon-detail/coupon-detail?id=${coupon.id}`
+    });
   }
-})
+});

+ 2 - 1
pages/coupon/coupon.json

@@ -1,6 +1,7 @@
 {
   "usingComponents": {
-    "header": "/components/Header/Header"
+    "header": "/components/Header/Header",
+    "van-empty": "@vant/weapp/empty/index"
   },
   "navigationStyle": "custom"
 }

+ 32 - 18
pages/coupon/coupon.wxml

@@ -1,25 +1,39 @@
 <view class="container">
   <header text="我的优惠券"></header>
-  <view class="content">
-    <view class="card-box">
-      <image class="card-img" src="/static/image/yhq.png" mode="aspectFit"/>
-      <view class="card-cont">
-          <view class="card-cont-lf">菜品券</view>
+  <scroll-view 
+    class="content"
+    scroll-y="true"
+    bindscrolltolower="onReachBottom"
+    lower-threshold="50"
+    refresher-enabled="true"
+    refresher-triggered="{{refreshing}}"
+    bindrefresherrefresh="onPullDownRefresh"
+  >
+    <!-- 有数据 -->
+    <block wx:if="{{couponList.length > 0}}">
+      <view class="card-box" wx:for="{{couponList}}" wx:key="index" bindtap="goPage">
+        <image class="card-img" src="/static/image/yhq.png" mode="aspectFit"/>
+        <view class="card-cont">
+          <view class="card-cont-lf">{{item.typeText}}</view>
           <view class="card-cont-ri">
-            <view>烤鸭券</view>
-            <view class="pop-time">2025-01-01到期</view>
+            <view>
+              <view>{{item.name}}</view>
+              <view class="pop-time">{{item.expireTime}}到期</view>
+            </view>
+            <view>
+              <image class="card-cont-status" src="{{item.statusImg}}" mode="aspectFit"/>
+            </view>
           </view>
         </view>
-    </view>
-    <view class="card-box">
-      <image class="card-img" src="/static/image/yhq.png" mode="aspectFit"/>
-      <view class="card-cont">
-          <view class="card-cont-lf">菜品券</view>
-          <view class="card-cont-ri">
-            <view>烤鸭券</view>
-            <view class="pop-time">2025-01-01到期</view>
-          </view>
-        </view>
-    </view>
+      </view>
+    </block>
+
+    <!-- 空状态 -->
+    <van-empty wx:if="{{!loadingMore && couponList.length === 0}}" description="暂无数据" />
+  </scroll-view>
+
+  <!-- 分页到底提示 -->
+  <view wx:if="{{!loadingMore && noMore && couponList.length > 0}}" class="loading">
+    没有更多数据了
   </view>
 </view>

+ 13 - 2
pages/coupon/coupon.wxss

@@ -22,7 +22,9 @@
   display: flex;
   align-items: center;
   box-sizing: border-box;
-  margin: 0 46rpx;
+  margin: 0 28rpx 0 46rpx;
+  left: 0;
+  right: 0;
 }
 .card-cont-lf{
   font-family: PingFangSC, PingFang SC;
@@ -37,7 +39,11 @@
   font-weight: 600;
   font-size: 28rpx;
   color: #000000;
-  line-height: 40rpx;
+  /* line-height: 40rpx; */
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  flex: 1;
 }
 .pop-time{
   font-family: PingFangSC, PingFang SC;
@@ -46,4 +52,9 @@
   color: #B0B0B0;
   line-height: 28rpx;
   margin-top: 6rpx;
+}
+.card-cont-status{
+  width: 140rpx;
+  height: 56rpx;
+  margin-top: 10rpx;
 }

+ 70 - 0
pages/couponDetail/couponDetail.js

@@ -0,0 +1,70 @@
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    status:0
+  },
+  goPage(){
+    wx.switchTab({
+      url: '/pages/store/store'
+    })
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})

+ 6 - 0
pages/couponDetail/couponDetail.json

@@ -0,0 +1,6 @@
+{
+  "usingComponents": {
+    "header": "/components/Header/Header"
+  },
+  "navigationStyle": "custom"
+}

+ 36 - 0
pages/couponDetail/couponDetail.wxml

@@ -0,0 +1,36 @@
+<view class="container">
+  <header text="我的优惠券"></header>
+  <view class="content">
+    <view wx:if="{{status == 0}}">
+      <view class="title">烤鸭券</view>
+      <view class="time">2025-01-01到期</view>
+    </view>
+    <view class="code-box" wx:if="{{status == 0}}">
+      <view class="code-img"></view>
+      <view class="code-text">使用时向服务业出示此码</view>
+      <view class="barcode">切换至条形码</view>
+    </view>
+    <view class="code-box" wx:if="{{status == 1}}">
+      <image class="yhx-img" src="/static/image/yhx-bg.png" mode="aspectFit"/>
+      <view class="code-yhx-text">已核销</view>
+      <view class="barcode-yhx">2020-01-01 12:23:12核销</view>
+    </view>
+    <view class="store-box" bindtap="goPage">
+      <view class="box-lf">
+        <image class="store-img" src="/static/image/md.png" mode="aspectFit"/>
+        <view>适用门店</view>
+      </view>
+      <view class="box-ri">
+        <view>去查看12家</view>
+        <image class="arrow-right" src="/static/image/arrow-right.png" mode="aspectFit"/>
+      </view>
+    </view>
+    <view class="explanation">
+      <image class="store-img" src="/static/image/sm.png" mode="aspectFit"/>
+      <view class="explanation-text">
+        <view>其他说明</view>
+        <view class="period">时段设置:全天可用 00:00-23:59</view>
+      </view>
+    </view>
+  </view>
+</view>

+ 124 - 0
pages/couponDetail/couponDetail.wxss

@@ -0,0 +1,124 @@
+.container{
+  height: 100vh;
+}
+.content{
+  flex: 1;
+  overflow: auto;
+  margin: 66rpx 56rpx 0;
+}
+.title{
+  font-family: PingFangSC, PingFang SC;
+  font-weight: 600;
+  font-size: 28rpx;
+  color: #000000;
+  line-height: 40rpx;
+}
+.time{
+  font-family: PingFangSC, PingFang SC;
+  font-weight: 400;
+  font-size: 24rpx;
+  color: #B0B0B0;
+  line-height: 34rpx;
+  margin-top: 10rpx;
+}
+.code-box{
+  margin-top: 94rpx;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  margin-bottom: 318rpx;
+}
+.code-img{
+  width: 264rpx;
+  height: 264rpx;
+  background: #FFFFFF;
+  border-radius: 20rpx;
+}
+.code-text{
+  font-family: PingFangSC, PingFang SC;
+  font-weight: 400;
+  font-size: 24rpx;
+  color: #8D8D8D;
+  line-height: 34rpx;
+  margin: 34rpx 0 16rpx;
+}
+.barcode{
+  font-family: PingFangSC, PingFang SC;
+  font-weight: 500;
+  font-size: 24rpx;
+  color: #FF5B00;
+  line-height: 34rpx;
+}
+.store-box{
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+  margin-bottom: 74rpx;
+}
+.box-lf,.box-ri{
+  display: flex;
+  align-items: center;
+}
+.box-lf{
+  font-family: PingFangSC, PingFang SC;
+  font-weight: 600;
+  font-size: 28rpx;
+  color: #000000;
+  line-height: 40rpx;
+}
+.box-ri{
+  font-family: PingFangSC, PingFang SC;
+  font-weight: 400;
+  font-size: 22rpx;
+  color: #BCBCBC;
+  line-height: 32rpx;
+}
+.store-img{
+  width: 36rpx;
+  height: 36rpx;
+  margin-right: 18rpx;
+}
+.arrow-right{
+  width: 12rpx;
+  height: 24rpx;
+  margin-left: 18rpx;
+}
+.explanation{
+  display: flex;
+  font-family: PingFangSC, PingFang SC;
+  font-weight: 600;
+  font-size: 28rpx;
+  color: #000000;
+  line-height: 40rpx;
+}
+.explanation-text{
+  position: relative;
+  top: -2px;
+}
+.period{
+  font-family: PingFangSC, PingFang SC;
+  font-weight: 400;
+  font-size: 24rpx;
+  color: #767676;
+  line-height: 40rpx;
+  margin-top: 18rpx;
+}
+.yhx-img{
+  width: 349.45rpx;
+  height: 236rpx;
+}
+.code-yhx-text{
+  margin: 30rpx 0 20rpx;
+  font-family: PingFangSC, PingFang SC;
+  font-weight: 500;
+  font-size: 24rpx;
+  color: #000000;
+  line-height: 34rpx;
+}
+.barcode-yhx{
+  font-family: PingFangSC, PingFang SC;
+  font-weight: 400;
+  font-size: 22rpx;
+  color: #BCBCBC;
+  line-height: 32rpx;
+}

+ 0 - 1
pages/index/index.js

@@ -52,7 +52,6 @@ Page({
   },
   onShareAppMessage() {
     return {
-      title: '这里是分享标题',
       path: '/pages/index/index',
       imageUrl: '/static/tabbar/weixin.png'
     }

+ 55 - 4
pages/register/register.js

@@ -1,4 +1,4 @@
-import { enroll } from '../../api/other';
+import { enroll,smsSend } from '../../api/other';
 const app = getApp();
 Page({
   data: {
@@ -8,7 +8,7 @@ Page({
       nickname: '',
       gender: '',        // '女' 或 '男'
       race_number: '',   // 身份证号
-      competition_no: '', // 比赛ID
+      // competition_no: '', // 比赛ID
       competition_image: '' // 上传的图片路径
     },
     phoneError: '', 
@@ -21,7 +21,11 @@ Page({
     canSubmit: false, // 按钮是否可点击
     showAgreementModal:false,
     agreementContent:'',
-    agreementTitle:''
+    agreementTitle:'',
+    codeText: '获取验证码',
+    codeDisabled: false,
+    timer: null,
+    countdown: 60
   },
 
   onShowPicker() {
@@ -34,6 +38,7 @@ Page({
     const { value } = event.detail;
     this.setData({ pickerValue: value });
   },
+  // 性别确定
   onConfirm() {
     this.setData({
       formData: {
@@ -93,6 +98,36 @@ Page({
     const valid = phone && captcha && nickname && gender && race_number && this.data.checked;
     this.setData({ canSubmit: valid });
   },
+  // 获取验证码
+  async getCode() {
+    if(this.data.codeDisabled) return;
+    const phone = this.data.formData.phone;
+    if (!phone) {
+      wx.showToast({
+        title: '请输入手机号',
+        icon: 'none'
+      });
+      return;
+    }
+    if (!/^1[3-9]\d{9}$/.test(phone)) {
+      wx.showToast({
+        title: '手机号格式不正确',
+        icon: 'none'
+      });
+      return;
+    }
+    // 禁用按钮
+    this.setData({ codeDisabled: true });
+    // 发送验证码请求给后台
+    const res = await smsSend({phone:this.data.formData.phone});
+    if (res.code == 200) {
+      wx.showToast({ title: '验证码已发送', icon: 'none' });
+      this.startCountdown();
+    } else {
+      wx.showToast({ title: res.message || '发送失败', icon: 'none' });
+      this.setData({ codeDisabled: false });
+    }
+  },
 
   // 提交报名
   async onSubmit() {
@@ -101,7 +136,6 @@ Page({
       ...this.data.formData,
       gender: this.data.formData.gender === '女' ? 0 : 1
     };
-
     const res = await enroll(payload);
     if (res.code === 200) {
       wx.showToast({ title: res.data, icon: 'none', duration: 2000 });
@@ -127,5 +161,22 @@ Page({
   onReceive() {
     this.setData({ showRegistrationSuccess: false });
     wx.navigateBack({ delta: 1 });
+  },
+  startCountdown() {
+    let countdown = this.data.countdown;
+    this.setData({ codeText: `${countdown}s` });
+    if (this.data.timer) clearInterval(this.data.timer);
+    this.data.timer = setInterval(() => {
+      countdown -= 1;
+      if (countdown <= 0) {
+        clearInterval(this.data.timer);
+        this.setData({ codeText: '获取验证码', codeDisabled: false, countdown: 60 });
+      } else {
+        this.setData({ codeText: `${countdown}s`, countdown });
+      }
+    }, 1000);
+  },
+  onUnload() {
+    if (this.data.timer) clearInterval(this.data.timer);
   }
 });

+ 6 - 3
pages/register/register.wxml

@@ -29,7 +29,10 @@
             placeholder="请输入验证码"
             border="{{ false }}"
           >
-            <view slot="button" class="from-code">获取验证码</view>
+            <view slot="button" 
+              class="from-code {{codeDisabled ? 'disabled' : ''}}" 
+              bindtap="getCode">{{codeText}}
+            </view>
           </van-field>
         </view>
 
@@ -73,7 +76,7 @@
         </view>
 
         <!-- 参赛号码 -->
-        <view class="from-li">
+        <!-- <view class="from-li">
           <image class="from-li-img img-w2" src="/static/image/register/cshm.png" mode="aspectFit" />
           <van-field
             model:value="{{formData.competition_no}}"
@@ -82,7 +85,7 @@
             placeholder="请输入参赛号码"
             border="{{ false }}"
           />
-        </view>
+        </view> -->
 
         <!-- 上传图片 -->
         <view class="from-li">

+ 4 - 0
pages/register/register.wxss

@@ -62,6 +62,10 @@
   color: #FF9200;
   line-height: 40rpx;
 }
+.from-code.disabled {
+  color: #999;
+  /* pointer-events: none; */
+}
 .from-icon{
   width: 26rpx;
   height: 14rpx;

+ 13 - 9
pages/registrationRecords/registrationRecords.js

@@ -2,12 +2,12 @@ import { enrollRecord } from '../../api/other';
 
 Page({
   data: {
-    cardList: [],        // 报名记录列表
-    page: 1,             // 当前页
-    pageSize: 2,         // 每页条数
-    loadingMore: false,  // 是否正在加载
-    noMore: false,       // 是否已没有更多数据
-    refreshing: false,    // 下拉刷新状态
+    cardList: [],
+    page: 1,
+    pageSize: 2,
+    loadingMore: false,
+    noMore: false,
+    refreshing: false
   },
 
   onLoad() {
@@ -26,18 +26,20 @@ Page({
         1: '/static/image/register/yjs.png',
         2: '/static/image/register/jxz.png'
       };
+
       const newList = res.data.list || [];
       let allList = isRefresh ? newList : [...this.data.cardList, ...newList];
       allList = allList.map(item => ({
         ...item,
         img: statusImgMap[item.status],
-        genderText:item.gender == 0?'女':'男'
+        genderText: item.gender == 0 ? '女' : '男'
       }));
+
       this.setData({
         cardList: allList,
         loadingMore: false,
         page: page + 1,
-        noMore: allList.length >= res.data.total,
+        noMore: allList.length >= res.data.total, // 有数据时判断是否加载完
         refreshing: false
       });
     } catch (err) {
@@ -49,15 +51,17 @@ Page({
       });
     }
   },
+
   // 上拉触底
   onReachBottom() {
     if (this.data.noMore) return;
     this.loadData();
   },
+
   // 下拉刷新
   onPullDownRefresh() {
     if (this.data.refreshing) return;
     this.setData({ refreshing: true, noMore: false, page: 1 });
     this.loadData(true);
   }
-});
+});

+ 2 - 1
pages/registrationRecords/registrationRecords.json

@@ -1,7 +1,8 @@
 {
   "usingComponents": {
     "header": "/components/Header/Header",
-    "van-cell": "@vant/weapp/cell/index"
+    "van-cell": "@vant/weapp/cell/index",
+    "van-empty": "@vant/weapp/empty/index"
   },
   "navigationStyle": "custom"
 }

+ 25 - 15
pages/registrationRecords/registrationRecords.wxml

@@ -9,22 +9,32 @@
     refresher-triggered="{{refreshing}}"
     bindrefresherrefresh="onPullDownRefresh"
   >
-    <view class="card-box {{ index === 0 ? 'first-card' : '' }}" wx:for="{{cardList}}" wx:key="index">
-      <view class="card-top">
-        <view class="card-title-box">
-          <view class="card-title">{{item.marathon_event.doings_name}}</view>
-          <view class="card-time">{{item.register_time}}</view>
+    <!-- 数据列表 -->
+    <block wx:if="{{cardList.length > 0}}">
+      <view class="card-box {{ index === 0 ? 'first-card' : '' }}" wx:for="{{cardList}}" wx:key="index">
+        <view class="card-top">
+          <view class="card-title-box">
+            <view class="card-title">{{item.marathon_event.doings_name}}</view>
+            <view class="card-time">{{item.register_time}}</view>
+          </view>
+          <image class="card-img" src="{{item.img}}" mode="aspectFit"/>
+        </view>
+        <view class="cell-box">
+          <van-cell title="参赛姓名" value="{{item.nickname}}" border="{{ false }}" />
+          <van-cell title="手机号" value="{{item.phone}}" border="{{ false }}" />
+          <van-cell title="性别" value="{{item.genderText}}" border="{{ false }}" />
+          <van-cell title="身份证号" value="{{item.race_number}}" border="{{ false }}" />
+          <van-cell custom-class="cell-list" title="参赛号码" value="{{item.competition_no}}" border="{{ false }}" />
         </view>
-        <image class="card-img" src="{{item.img}}" mode="aspectFit"/>
-      </view>
-      <view class="cell-box">
-        <van-cell title="参赛姓名" value="{{item.nickname}}" border="{{ false }}" />
-        <van-cell title="手机号" value="{{item.phone}}" border="{{ false }}" />
-        <van-cell title="性别" value="{{item.genderText}}" border="{{ false }}" />
-        <van-cell title="身份证号" value="{{item.race_number}}" border="{{ false }}" />
-        <van-cell custom-class="cell-list" title="参赛号码" value="{{item.competition_no}}" border="{{ false }}" />
       </view>
-    </view>
+    </block>
+
+    <!-- 空状态 -->
+    <van-empty wx:if="{{!loadingMore && cardList.length === 0}}" description="暂无数据" />
   </scroll-view>
-  <view wx:if="{{noMore}}" class="loading">没有更多数据了</view>
+
+  <!-- 分页到底提示 -->
+  <view wx:if="{{!loadingMore && noMore && cardList.length > 0}}" class="loading">
+    没有更多数据了
+  </view>
 </view>

+ 18 - 52
pages/storeDetail/storeDetail.js

@@ -1,15 +1,12 @@
 import { storeDetail } from '../../api/other';
 import { MAKE_PHONE_CALL } from '../../utils/util.js';
+// import amapFile from '../../utils/amap-wx.130.js';
 Page({
   data: {
     dataInfo:{},
     latitude:0,
     longitude:0
   },
-
-  /**
-   * 生命周期函数--监听页面加载
-   */
   onLoad(options) {
     wx.getLocation({
       type: 'wgs84',
@@ -42,55 +39,24 @@ Page({
       wx.showToast({ title: res.message || '加载失败', icon: 'none' });
     }
   },
+  onAddress(){
+    wx.openLocation({
+    latitude: this.data.dataInfo.latitude * 1, // 纬度
+    longitude: this.data.dataInfo.longitude * 1, // 经度
+    name:this.data.dataInfo.name,
+    address: this.data.dataInfo.address,
+  })
+    // const myAmap = new amapFile.AMapWX({ key: '9570ea64f637d1744ec4944bc909176a' });
+    // myAmap.getPoiAround({
+    //   success: data => {
+    //     console.log('周边POI:', data);
+    //   },
+    //   fail: info => {
+    //     console.error(info);
+    //   }
+    // });
+  },
   onPhone(){
     MAKE_PHONE_CALL(this.data.dataInfo.phone);
   },
-  /**
-   * 生命周期函数--监听页面初次渲染完成
-   */
-  onReady() {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面显示
-   */
-  onShow() {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面隐藏
-   */
-  onHide() {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面卸载
-   */
-  onUnload() {
-
-  },
-
-  /**
-   * 页面相关事件处理函数--监听用户下拉动作
-   */
-  onPullDownRefresh() {
-
-  },
-
-  /**
-   * 页面上拉触底事件的处理函数
-   */
-  onReachBottom() {
-
-  },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage() {
-
-  }
 })

+ 1 - 1
pages/storeDetail/storeDetail.wxml

@@ -12,7 +12,7 @@
     <view class="address">
       <view class="address-text">{{dataInfo.address}}</view>
       <view class="address-icon">
-        <image class="ad-img" src="/static/image/address.png" mode="aspectFit"/>
+        <image class="ad-img" src="/static/image/address.png" mode="aspectFit" bindtap="onAddress"/>
         <image class="ad-img" src="/static/image/phone.png" mode="aspectFit" bindtap="onPhone"/>
       </view>
     </view>

BIN
static/image/arrow-right.png


BIN
static/image/cover.jpg


BIN
static/image/md.png


BIN
static/image/sm.png


BIN
static/image/whx.png


BIN
static/image/yhx-bg.png


BIN
static/image/yhx.png


+ 31 - 0
utils/amap-wx.130.js

@@ -0,0 +1,31 @@
+function AMapWX(a){this.key=a.key;this.requestConfig={key:a.key,s:"rsx",platform:"WXJS",appname:a.key,sdkversion:"1.2.0",logversion:"2.0"};this.MeRequestConfig={key:a.key,serviceName:"https://restapi.amap.com/rest/me"}}
+AMapWX.prototype.getWxLocation=function(a,b){wx.getLocation({type:"gcj02",success:function(c){c=c.longitude+","+c.latitude;wx.setStorage({key:"userLocation",data:c});b(c)},fail:function(c){wx.getStorage({key:"userLocation",success:function(d){d.data&&b(d.data)}});a.fail({errCode:"0",errMsg:c.errMsg||""})}})};
+AMapWX.prototype.getMEKeywordsSearch=function(a){if(!a.options)return a.fail({errCode:"0",errMsg:"\u7f3a\u5c11\u5fc5\u8981\u53c2\u6570"});var b=a.options,c=this.MeRequestConfig,d={key:c.key,s:"rsx",platform:"WXJS",appname:a.key,sdkversion:"1.2.0",logversion:"2.0"};b.layerId&&(d.layerId=b.layerId);b.keywords&&(d.keywords=b.keywords);b.city&&(d.city=b.city);b.filter&&(d.filter=b.filter);b.sortrule&&(d.sortrule=b.sortrule);b.pageNum&&(d.pageNum=b.pageNum);b.pageSize&&(d.pageSize=b.pageSize);b.sig&&(d.sig=
+b.sig);wx.request({url:c.serviceName+"/cpoint/datasearch/local",data:d,method:"GET",header:{"content-type":"application/json"},success:function(e){(e=e.data)&&e.status&&"1"===e.status&&0===e.code?a.success(e.data):a.fail({errCode:"0",errMsg:e})},fail:function(e){a.fail({errCode:"0",errMsg:e.errMsg||""})}})};
+AMapWX.prototype.getMEIdSearch=function(a){if(!a.options)return a.fail({errCode:"0",errMsg:"\u7f3a\u5c11\u5fc5\u8981\u53c2\u6570"});var b=a.options,c=this.MeRequestConfig,d={key:c.key,s:"rsx",platform:"WXJS",appname:a.key,sdkversion:"1.2.0",logversion:"2.0"};b.layerId&&(d.layerId=b.layerId);b.id&&(d.id=b.id);b.sig&&(d.sig=b.sig);wx.request({url:c.serviceName+"/cpoint/datasearch/id",data:d,method:"GET",header:{"content-type":"application/json"},success:function(e){(e=e.data)&&e.status&&"1"===e.status&&
+0===e.code?a.success(e.data):a.fail({errCode:"0",errMsg:e})},fail:function(e){a.fail({errCode:"0",errMsg:e.errMsg||""})}})};
+AMapWX.prototype.getMEPolygonSearch=function(a){if(!a.options)return a.fail({errCode:"0",errMsg:"\u7f3a\u5c11\u5fc5\u8981\u53c2\u6570"});var b=a.options,c=this.MeRequestConfig,d={key:c.key,s:"rsx",platform:"WXJS",appname:a.key,sdkversion:"1.2.0",logversion:"2.0"};b.layerId&&(d.layerId=b.layerId);b.keywords&&(d.keywords=b.keywords);b.polygon&&(d.polygon=b.polygon);b.filter&&(d.filter=b.filter);b.sortrule&&(d.sortrule=b.sortrule);b.pageNum&&(d.pageNum=b.pageNum);b.pageSize&&(d.pageSize=b.pageSize);
+b.sig&&(d.sig=b.sig);wx.request({url:c.serviceName+"/cpoint/datasearch/polygon",data:d,method:"GET",header:{"content-type":"application/json"},success:function(e){(e=e.data)&&e.status&&"1"===e.status&&0===e.code?a.success(e.data):a.fail({errCode:"0",errMsg:e})},fail:function(e){a.fail({errCode:"0",errMsg:e.errMsg||""})}})};
+AMapWX.prototype.getMEaroundSearch=function(a){if(!a.options)return a.fail({errCode:"0",errMsg:"\u7f3a\u5c11\u5fc5\u8981\u53c2\u6570"});var b=a.options,c=this.MeRequestConfig,d={key:c.key,s:"rsx",platform:"WXJS",appname:a.key,sdkversion:"1.2.0",logversion:"2.0"};b.layerId&&(d.layerId=b.layerId);b.keywords&&(d.keywords=b.keywords);b.center&&(d.center=b.center);b.radius&&(d.radius=b.radius);b.filter&&(d.filter=b.filter);b.sortrule&&(d.sortrule=b.sortrule);b.pageNum&&(d.pageNum=b.pageNum);b.pageSize&&
+(d.pageSize=b.pageSize);b.sig&&(d.sig=b.sig);wx.request({url:c.serviceName+"/cpoint/datasearch/around",data:d,method:"GET",header:{"content-type":"application/json"},success:function(e){(e=e.data)&&e.status&&"1"===e.status&&0===e.code?a.success(e.data):a.fail({errCode:"0",errMsg:e})},fail:function(e){a.fail({errCode:"0",errMsg:e.errMsg||""})}})};
+AMapWX.prototype.getGeo=function(a){var b=this.requestConfig,c=a.options;b={key:this.key,extensions:"all",s:b.s,platform:b.platform,appname:this.key,sdkversion:b.sdkversion,logversion:b.logversion};c.address&&(b.address=c.address);c.city&&(b.city=c.city);c.batch&&(b.batch=c.batch);c.sig&&(b.sig=c.sig);wx.request({url:"https://restapi.amap.com/v3/geocode/geo",data:b,method:"GET",header:{"content-type":"application/json"},success:function(d){(d=d.data)&&d.status&&"1"===d.status?a.success(d):a.fail({errCode:"0",
+errMsg:d})},fail:function(d){a.fail({errCode:"0",errMsg:d.errMsg||""})}})};
+AMapWX.prototype.getRegeo=function(a){function b(d){var e=c.requestConfig;wx.request({url:"https://restapi.amap.com/v3/geocode/regeo",data:{key:c.key,location:d,extensions:"all",s:e.s,platform:e.platform,appname:c.key,sdkversion:e.sdkversion,logversion:e.logversion},method:"GET",header:{"content-type":"application/json"},success:function(g){if(g.data.status&&"1"==g.data.status){g=g.data.regeocode;var h=g.addressComponent,f=[],k=g.roads[0].name+"\u9644\u8fd1",m=d.split(",")[0],n=d.split(",")[1];if(g.pois&&
+g.pois[0]){k=g.pois[0].name+"\u9644\u8fd1";var l=g.pois[0].location;l&&(m=parseFloat(l.split(",")[0]),n=parseFloat(l.split(",")[1]))}h.provice&&f.push(h.provice);h.city&&f.push(h.city);h.district&&f.push(h.district);h.streetNumber&&h.streetNumber.street&&h.streetNumber.number?(f.push(h.streetNumber.street),f.push(h.streetNumber.number)):f.push(g.roads[0].name);f=f.join("");a.success([{iconPath:a.iconPath,width:a.iconWidth,height:a.iconHeight,name:f,desc:k,longitude:m,latitude:n,id:0,regeocodeData:g}])}else a.fail({errCode:g.data.infocode,
+errMsg:g.data.info})},fail:function(g){a.fail({errCode:"0",errMsg:g.errMsg||""})}})}var c=this;a.location?b(a.location):c.getWxLocation(a,function(d){b(d)})};
+AMapWX.prototype.getWeather=function(a){function b(g){var h="base";a.type&&"forecast"==a.type&&(h="all");wx.request({url:"https://restapi.amap.com/v3/weather/weatherInfo",data:{key:d.key,city:g,extensions:h,s:e.s,platform:e.platform,appname:d.key,sdkversion:e.sdkversion,logversion:e.logversion},method:"GET",header:{"content-type":"application/json"},success:function(f){if(f.data.status&&"1"==f.data.status)if(f.data.lives){if((f=f.data.lives)&&0<f.length){f=f[0];var k={city:{text:"\u57ce\u5e02",data:f.city},
+weather:{text:"\u5929\u6c14",data:f.weather},temperature:{text:"\u6e29\u5ea6",data:f.temperature},winddirection:{text:"\u98ce\u5411",data:f.winddirection+"\u98ce"},windpower:{text:"\u98ce\u529b",data:f.windpower+"\u7ea7"},humidity:{text:"\u6e7f\u5ea6",data:f.humidity+"%"}};k.liveData=f;a.success(k)}}else f.data.forecasts&&f.data.forecasts[0]&&a.success({forecast:f.data.forecasts[0]});else a.fail({errCode:f.data.infocode,errMsg:f.data.info})},fail:function(f){a.fail({errCode:"0",errMsg:f.errMsg||""})}})}
+function c(g){wx.request({url:"https://restapi.amap.com/v3/geocode/regeo",data:{key:d.key,location:g,extensions:"all",s:e.s,platform:e.platform,appname:d.key,sdkversion:e.sdkversion,logversion:e.logversion},method:"GET",header:{"content-type":"application/json"},success:function(h){if(h.data.status&&"1"==h.data.status){h=h.data.regeocode;if(h.addressComponent)var f=h.addressComponent.adcode;else h.aois&&0<h.aois.length&&(f=h.aois[0].adcode);b(f)}else a.fail({errCode:h.data.infocode,errMsg:h.data.info})},
+fail:function(h){a.fail({errCode:"0",errMsg:h.errMsg||""})}})}var d=this,e=d.requestConfig;a.city?b(a.city):d.getWxLocation(a,function(g){c(g)})};
+AMapWX.prototype.getPoiAround=function(a){function b(e){e={key:c.key,location:e,s:d.s,platform:d.platform,appname:c.key,sdkversion:d.sdkversion,logversion:d.logversion};a.querytypes&&(e.types=a.querytypes);a.querykeywords&&(e.keywords=a.querykeywords);wx.request({url:"https://restapi.amap.com/v3/place/around",data:e,method:"GET",header:{"content-type":"application/json"},success:function(g){if(g.data.status&&"1"==g.data.status){if((g=g.data)&&g.pois){for(var h=[],f=0;f<g.pois.length;f++){var k=0==
+f?a.iconPathSelected:a.iconPath;h.push({latitude:parseFloat(g.pois[f].location.split(",")[1]),longitude:parseFloat(g.pois[f].location.split(",")[0]),iconPath:k,width:22,height:32,id:f,name:g.pois[f].name,address:g.pois[f].address})}a.success({markers:h,poisData:g.pois})}}else a.fail({errCode:g.data.infocode,errMsg:g.data.info})},fail:function(g){a.fail({errCode:"0",errMsg:g.errMsg||""})}})}var c=this,d=c.requestConfig;a.location?b(a.location):c.getWxLocation(a,function(e){b(e)})};
+AMapWX.prototype.getStaticmap=function(a){function b(e){c.push("location="+e);a.zoom&&c.push("zoom="+a.zoom);a.size&&c.push("size="+a.size);a.scale&&c.push("scale="+a.scale);a.markers&&c.push("markers="+a.markers);a.labels&&c.push("labels="+a.labels);a.paths&&c.push("paths="+a.paths);a.traffic&&c.push("traffic="+a.traffic);e="https://restapi.amap.com/v3/staticmap?"+c.join("&");a.success({url:e})}var c=[];c.push("key="+this.key);var d=this.requestConfig;c.push("s="+d.s);c.push("platform="+d.platform);
+c.push("appname="+d.appname);c.push("sdkversion="+d.sdkversion);c.push("logversion="+d.logversion);a.location?b(a.location):this.getWxLocation(a,function(e){b(e)})};
+AMapWX.prototype.getInputtips=function(a){var b=Object.assign({},this.requestConfig);a.location&&(b.location=a.location);a.keywords&&(b.keywords=a.keywords);a.type&&(b.type=a.type);a.city&&(b.city=a.city);a.citylimit&&(b.citylimit=a.citylimit);wx.request({url:"https://restapi.amap.com/v3/assistant/inputtips",data:b,method:"GET",header:{"content-type":"application/json"},success:function(c){c&&c.data&&c.data.tips&&a.success({tips:c.data.tips})},fail:function(c){a.fail({errCode:"0",errMsg:c.errMsg||
+""})}})};
+AMapWX.prototype.getDrivingRoute=function(a){var b=Object.assign({},this.requestConfig);a.origin&&(b.origin=a.origin);a.destination&&(b.destination=a.destination);a.strategy&&(b.strategy=a.strategy);a.waypoints&&(b.waypoints=a.waypoints);a.avoidpolygons&&(b.avoidpolygons=a.avoidpolygons);a.avoidroad&&(b.avoidroad=a.avoidroad);wx.request({url:"https://restapi.amap.com/v3/direction/driving",data:b,method:"GET",header:{"content-type":"application/json"},success:function(c){c&&c.data&&c.data.route&&a.success({paths:c.data.route.paths,
+taxi_cost:c.data.route.taxi_cost||""})},fail:function(c){a.fail({errCode:"0",errMsg:c.errMsg||""})}})};
+AMapWX.prototype.getWalkingRoute=function(a){var b=Object.assign({},this.requestConfig);a.origin&&(b.origin=a.origin);a.destination&&(b.destination=a.destination);wx.request({url:"https://restapi.amap.com/v3/direction/walking",data:b,method:"GET",header:{"content-type":"application/json"},success:function(c){c&&c.data&&c.data.route&&a.success({paths:c.data.route.paths})},fail:function(c){a.fail({errCode:"0",errMsg:c.errMsg||""})}})};
+AMapWX.prototype.getTransitRoute=function(a){var b=Object.assign({},this.requestConfig);a.origin&&(b.origin=a.origin);a.destination&&(b.destination=a.destination);a.strategy&&(b.strategy=a.strategy);a.city&&(b.city=a.city);a.cityd&&(b.cityd=a.cityd);wx.request({url:"https://restapi.amap.com/v3/direction/transit/integrated",data:b,method:"GET",header:{"content-type":"application/json"},success:function(c){c&&c.data&&c.data.route&&(c=c.data.route,a.success({distance:c.distance||"",taxi_cost:c.taxi_cost||
+"",transits:c.transits}))},fail:function(c){a.fail({errCode:"0",errMsg:c.errMsg||""})}})};
+AMapWX.prototype.getRidingRoute=function(a){var b=Object.assign({},this.requestConfig);a.origin&&(b.origin=a.origin);a.destination&&(b.destination=a.destination);wx.request({url:"https://restapi.amap.com/v3/direction/riding",data:b,method:"GET",header:{"content-type":"application/json"},success:function(c){c&&c.data&&c.data.route&&a.success({paths:c.data.route.paths})},fail:function(c){a.fail({errCode:"0",errMsg:c.errMsg||""})}})};module.exports.AMapWX=AMapWX;

+ 13 - 0
utils/request.js

@@ -22,6 +22,19 @@ function request({ loading = true, url, method = 'GET', data = {}, header = {} }
         if (loading) wx.hideLoading();
         if (res.statusCode === 200) {
           resolve(res.data);
+        } else if (res.statusCode === 401) {
+          wx.showToast({
+            title: '登录已失效,请重新登录',
+            icon: 'none',
+            duration: 2000
+          });
+          wx.removeStorageSync('token');
+          setTimeout(() => {
+            wx.reLaunch({
+              url: '/pages/index/index'
+            });
+          }, 1000);
+          reject(res.data);
         } else {
           wx.showToast({
             title: res.data?.message || '请求错误',