SilenceLeo il y a 3 ans
Parent
commit
e56a045f8d
9 fichiers modifiés avec 318 ajouts et 235 suppressions
  1. 31 18
      README.md
  2. 14 0
      src/lib/api/shop.js
  3. 8 0
      src/lib/api/user.js
  4. 26 0
      src/pages.json
  5. 17 2
      src/pages/my/edit.vue
  6. 38 4
      src/pages/my/my.vue
  7. 69 0
      src/pages/shop/detail.vue
  8. 24 144
      src/pages/shop/list.scss
  9. 91 67
      src/pages/shop/list.vue

+ 31 - 18
README.md

@@ -1,42 +1,55 @@
-## 一、首页 ```/pages/index/index```
+## 一、首页 `/pages/index/index`
+
 1. 轮播 -> 抽一番赏
-2. 会员权益  vip会员  签到  自主积分  会员活动  商务合作
-3. 最新推荐  -> 店铺相关推荐
+2. 会员权益 vip 会员 签到 自主积分 会员活动 商务合作
+3. 最新推荐 -> 店铺相关推荐
 
 ## 二、会员权益 /pages/vip/index
-1. 普通会员  vip会员 ```/pages/vip/index```
-2. 权益名称 所属会员  logo  介绍  权重 ```/pages/vip/detail?id=xxx```
 
-## 三、vip会员 ```/pages/vip/vip```
+1. 普通会员 vip 会员 `/pages/vip/index`
+2. 权益名称 所属会员 logo 介绍 权重 `/pages/vip/detail?id=xxx`
+
+## 三、vip 会员 `/pages/vip/vip`
+
 1. 介绍页 写死,权限只是展示,不可点击,
 2. 已开通 不显示开通按钮
 3. 点击立即开通,弹出弹框,限时 开通会员名称 会员有效期 开始/结束时间。
 
-## 四、签到 ```/pages/task/index```
-1. 和 初见潮玩 保持一致 
+## 四、签到 `/pages/task/index`
+
+1. 和 初见潮玩 保持一致
+
+## 五、自主积分 和 大悦城保持一致 `/pages/task/index`
 
-## 五、自主积分  和 大悦城保持一致 ```/pages/task/index```
-1. 卡片  显示当前积分
-2. 两个按钮: 拍照积分  积分兑换(?)
+1. 卡片 显示当前积分
+2. 两个按钮: 拍照积分 积分兑换(?)
 3. 积分申请记录(图片/名称/时间/状态)
 
-### 五.1、积分商城(兑换) ```/pages/shop/index```
+### 五.1、积分商城(兑换) `/pages/shop/index`
+
 1. 商品列表(图片/标题/积分/兑换按钮/状态)
 
-## 六、会员活动 
-1. 显示活动列表(图片/名称/时间) ```/pages/activity/index```
-2. 活动详情(标题/时间/详情(img)/规则/按钮(有些有/有些没))  ```/pages/activity/detail?id=xxx```
+## 六、会员活动
+
+1. 显示活动列表(图片/名称/时间) `/pages/activity/index`
+2. 活动详情(标题/时间/详情(img)/规则/按钮(有些有/有些没)) `/pages/activity/detail?id=xxx`
+
+## 七、商务合作 (招商人信息(名称/邮箱/电话)) `/pages/help/contact`
 
-## 七、商务合作 (招商人信息(名称/邮箱/电话)) ```/pages/help/contact```
+## 八、我的(我的信息/马上加入 vip 会员/卡片/我的卡包入口) `/pages/my/my`
 
-## 八、我的(我的信息/马上加入vip会员/卡片/我的卡包入口)  ```/pages/my/my```
+## 九、我的卡包 `/pages/my/coupon`
 
-## 九、我的卡包 ```/pages/my/coupon```
 1. 可用/历史
    - 物品/优惠券
 
 ## 十、初见潮玩 - 抽一番赏
 
+## 十一、商铺
+
+列表 `/pages/shop/list`
+
+详情 `/pages/shop/detail?id=xxx`
 
 ## Api
 

+ 14 - 0
src/lib/api/shop.js

@@ -43,3 +43,17 @@ export const getScoreList = () => request.get("/weapp/score/list");
  */
 export const uploadPhoto = (data) =>
   request.post("/weapp/score/photo/upload", data);
+
+/**
+ * 店铺列表页
+ *
+ * [API](https://console-docs.apipost.cn/preview/888dcf083e39e4e4/ae9a5ffd745e57d1?target_id=992f53fb-051f-48cc-b2d4-31d18b45ba35)
+ */
+export const getShopList = () => request.get("/weapp/shops/list");
+
+/**
+ * 店铺详情页
+ *
+ * [API](https://console-docs.apipost.cn/preview/888dcf083e39e4e4/ae9a5ffd745e57d1?target_id=589cd780-4901-46e6-8a91-f0681300359b)
+ */
+export const getShopDetail = (id) => request.get(`/weapp/shops/${id}`);

+ 8 - 0
src/lib/api/user.js

@@ -5,3 +5,11 @@ import request from "../utils/request";
  *
  */
 export const getUserInfo = () => request.get("/weapp/userInfo");
+
+/**
+ * 修改个人昵称
+ *
+ * [API](https://console-docs.apipost.cn/preview/888dcf083e39e4e4/ae9a5ffd745e57d1?target_id=893191f5-fb56-4080-b75f-4e144f5e5d0e)
+ */
+export const setNickname = (data) =>
+  request.post("/weapp/update/nickname", data);

+ 26 - 0
src/pages.json

@@ -34,6 +34,24 @@
         "backgroundColor": "#F7F7FC"
       }
     },
+    {
+      "path": "pages/shop/list",
+      "style": {
+        "navigationBarTitleText": "商户列表",
+        "enablePullDownRefresh": true,
+        "navigationBarBackgroundColor": "#F7F7FC",
+        "backgroundColor": "#F7F7FC"
+      }
+    },
+    {
+      "path": "pages/shop/detail",
+      "style": {
+        "navigationBarTitleText": "商户详情",
+        "enablePullDownRefresh": true,
+        "navigationBarBackgroundColor": "#F7F7FC",
+        "backgroundColor": "#F7F7FC"
+      }
+    },
     {
       "path": "pages/activity/index",
       "style": {
@@ -329,6 +347,14 @@
         "name": "卡券",
         "path": "pages/my/coupon"
       },
+      {
+        "name": "vip卡片",
+        "path": "pages/vip/card"
+      },
+      {
+        "name": "门店列表",
+        "path": "pages/shop/list"
+      },
       {
         "name": "vip卡片",
         "path": "pages/vip/card"

+ 17 - 2
src/pages/my/edit.vue

@@ -3,6 +3,14 @@
     <form @submit.prevent="handleSubmit">
       <view class="form-item">
         <input
+          v-if="type === 'nickname'"
+          v-model="text"
+          type="text"
+          class="form-input"
+          placeholder="请填写昵称"
+        />
+        <input
+          v-else
           v-model="text"
           type="text"
           class="form-input"
@@ -26,7 +34,7 @@
 
 <script>
 import login from "@/lib/utils/login";
-import { getUserInfo } from "@/lib/api/user";
+import { getUserInfo, setNickname } from "@/lib/api/user";
 import { postBd } from "@/lib/api/other";
 
 export default {
@@ -35,6 +43,7 @@ export default {
     return {
       userInfo: {},
       text: "",
+      type: "",
     };
   },
   computed: {
@@ -42,6 +51,9 @@ export default {
       return !this.text.trim();
     },
   },
+  onLoad(data) {
+    this.type = data.type || "";
+  },
   async onShow() {
     this.userInfo = await login.getUserInfo();
     this.getUserInfo();
@@ -59,7 +71,10 @@ export default {
         });
     },
     async handleSubmit() {
-      const res = await postBd({ bd: this.text });
+      const res = await (this.type === "nickname"
+        ? setNickname({ name: this.text })
+        : postBd({ bd: this.text }));
+
       if (res.errno === 10000) {
         uni.showToast({
           icon: "none",

+ 38 - 4
src/pages/my/my.vue

@@ -5,11 +5,17 @@
         v-if="userInfo.show_id && userInfo.session && userInfo.phone"
         class="user-box"
       >
-        <image class="avatar" :src="userInfo.avatar" mode=""></image>
+        <button
+          class="avatar-btn"
+          open-type="chooseAvatar"
+          @chooseavatar="handleChooseAvatar"
+        >
+          <image class="avatar" :src="userInfo.avatar" mode=""></image>
+        </button>
         <view class="user-body">
-          <text class="user-name">
+          <navigator class="user-name" url="/pages/my/edit?type=nickname">
             {{ userInfo.nickname }}
-          </text>
+          </navigator>
           <!-- <text class="user-id" @click="handleCopyId"
             >ID: {{ userInfo.show_id }} <text class="copy">复制</text></text
           > -->
@@ -94,6 +100,7 @@
 
 <script>
 import login from "@/lib/utils/login";
+import request from "@/lib/utils/request";
 import { getUserInfo } from "@/lib/api/user";
 import VipCard from "@/components/vip-card/vip-card.vue";
 
@@ -245,6 +252,24 @@ export default {
     handleLogin(userInfo) {
       this.userInfo = userInfo;
     },
+
+    handleChooseAvatar(e) {
+      uni.uploadFile({
+        url: "https://yggc.weapp.yergoo.com/weapp/update/avatar", //仅为示例,非真实的接口地址
+        filePath: e.detail.avatarUrl,
+        name: "f",
+        header: request.getCommonHeader(),
+        timeout: 30000,
+        success: (uploadFileRes) => {
+          const res = JSON.parse(uploadFileRes.data);
+          uni.showToast({
+            icon: "none",
+            title: res.errno === 10000 ? "上传成功" : res.errmsg,
+          });
+          if (res.errno === 10000) this.getUserInfo();
+        },
+      });
+    },
   },
 };
 </script>
@@ -266,10 +291,19 @@ export default {
   .user-box {
     display: flex;
     align-items: center;
-    .avatar {
+    .avatar-btn {
       width: 96rpx;
       height: 96rpx;
       margin-right: 18rpx;
+      padding: 0;
+      border-radius: 100%;
+      &::after {
+        display: none;
+      }
+    }
+    .avatar {
+      width: 96rpx;
+      height: 96rpx;
       border-radius: 100%;
     }
     .user-btn {

+ 69 - 0
src/pages/shop/detail.vue

@@ -0,0 +1,69 @@
+<template>
+  <view class="page">
+    <view class="title">
+      <view class="name">{{ data.name }}</view>
+      <image :src="data.logo" class="logo"></image>
+    </view>
+    <view class="content">
+      <view class="content-title">权益介绍</view>
+      <view v-html="data.intro" />
+    </view>
+  </view>
+</template>
+
+<script>
+import { getShopDetail } from "@/lib/api/shop";
+
+export default {
+  name: "VipDetail",
+  data() {
+    return {
+      id: 0,
+      data: null,
+    };
+  },
+  onLoad(data) {
+    this.id = data.id;
+    this.getShopDetail();
+  },
+  methods: {
+    async getShopDetail() {
+      const data = await getShopDetail(this.id);
+      this.data = data.data;
+    },
+  },
+};
+</script>
+
+<style lang="scss">
+page {
+  background: #f5f5f5;
+}
+.title {
+  display: flex;
+  align-items: center;
+  margin: 40rpx;
+  padding: 40rpx;
+  background-color: #fff;
+  border-radius: 20rpx;
+  .name {
+    flex: 1;
+    font-weight: bold;
+  }
+  .logo {
+    display: block;
+    width: 100rpx;
+    height: 100rpx;
+  }
+}
+.content {
+  padding: 30rpx 40rpx;
+  font-size: 28rpx;
+  line-height: 1.5;
+  background-color: #fff;
+  .content-title {
+    margin-bottom: 20rpx;
+    font-size: 36rpx;
+  }
+}
+</style>

+ 24 - 144
src/pages/shop/list.scss

@@ -1,149 +1,29 @@
-text {
-  letter-spacing: 0.3px;
+.wrap {
+  width: 100%;
+  box-sizing: border-box;
+  padding: 40rpx;
+  min-height: 100vh;
+  background-color: #f7f7fc;
 }
-.home-list {
-  width: 750rpx;
-  background: #f5f5f5;
-  height: 100%;
-  .list {
-    margin: 20rpx 20rpx 0;
-    .r {
-      width: 100%;
-      height: 240rpx;
-      margin: 0rpx 0rpx 20rpx;
-      .r1 {
-        width: 240rpx;
-        position: relative;
-        img {
-          border-radius: 8rpx;
-          height: 240rpx;
-          width: 240rpx;
-        }
-        .tag {
-          position: absolute;
-          background: linear-gradient(45deg, #ff8104 10%, #ffcd71 100%);
-          text-align: center;
-          color: #ffffff;
-          letter-spacing: 1rpx;
-          font-size: 20rpx;
-          top: 6rpx;
-          left: 6rpx;
-          font-weight: 500;
-          padding: 4rpx 10rpx 6rpx;
-          border-radius: 8rpx;
-        }
-      }
-      .r2 {
-        width: 412rpx;
-        margin-left: 18rpx;
-        height: 240rpx;
-        position: relative;
-        .n1 {
-          width: 100%;
-          height: 40rpx;
-          margin-bottom: 50rpx;
-          text {
-            width: 100%;
-            font-size: 28rpx;
-            font-weight: 550;
-            color: #26272c;
-            line-height: 40rpx;
-            overflow: hidden;
-            white-space: nowrap;
-            word-break: break-all; /* break-all(允许在单词内换行。) */
-            text-overflow: ellipsis; /* 超出部分省略号 */
-            display: block;
-          }
-        }
-        .tag {
-          border: 1rpx solid #ff9f5b;
-          text-align: center;
-          color: #ff9f5b;
-          letter-spacing: 1rpx;
-          font-size: 20rpx;
-          font-weight: 500;
-          padding: 0rpx 10rpx;
-          line-height: 33rpx;
-          text-align: center;
-          height: 33rpx;
-          border-radius: 8rpx;
-          position: absolute;
-          top: 48rpx;
-          display: inline-block;
-        }
-        .n2 {
-          height: 50rpx;
-          margin-top: 8rpx;
-          .price1 {
-            height: 50rpx;
-            font-size: 22rpx;
-            font-weight: 550;
-            color: #ec2e56;
-            line-height: 40rpx;
-            letter-spacing: 1rpx;
-            text {
-              margin-left: 4rpx;
-              font-size: 28rpx;
-            }
-          }
-          .price2 {
-            text-decoration: line-through;
-            margin-left: 8rpx;
-            height: 34rpx;
-            font-size: 24rpx;
-            font-weight: 550;
-            color: #999999;
-            line-height: 34rpx;
-            letter-spacing: 1rpx;
-            text {
-              margin-left: 4rpx;
-            }
-          }
-        }
-        .n3 {
-          height: 96rpx;
-          margin-top: 8rpx;
-          img {
-            height: 96rpx;
-            width: 96rpx;
-            border-radius: 6rpx;
-          }
-        }
-      }
-    }
+
+.item {
+  display: flex;
+  align-items: center;
+  margin: 30rpx auto;
+  padding: 20rpx;
+  background-color: #fff;
+  box-shadow: 0 0 5px rgba($color: #000000, $alpha: 0.1);
+  border-radius: 20rpx;
+  .item-img {
+    width: 200rpx;
+    height: 150rpx;
+    margin-right: 20rpx;
+    background-color: #f7f7fc;
   }
-  .gc-1 {
-    width: 710rpx;
-    margin: 20rpx 20rpx 0;
-    background-color: #ffffff;
-    border-radius: 16rpx;
-    .line {
-      margin-bottom: 20rpx;
-      width: 100%;
-      height: 2rpx;
-      background-color: #f5f5f5;
-    }
+  .item-body {
+    flex: 1;
+    width: 0;
   }
-  .footer {
-    width: 100%;
-    margin-top: 16rpx;
-    margin-bottom: 22rpx;
-    .info {
-      height: 40rpx;
-      font-size: 28rpx;
-      font-weight: 500;
-      color: #999999;
-      line-height: 40rpx;
-      text-align: center;
-    }
-    .contact {
-      margin-top: 8rpx;
-      height: 40rpx;
-      font-size: 28rpx;
-      font-weight: 500;
-      color: #999999;
-      line-height: 40rpx;
-      text-align: center;
-    }
+  .item-name {
   }
 }

+ 91 - 67
src/pages/shop/list.vue

@@ -1,101 +1,125 @@
 <template>
-  <view class="home-list flex-col">
-    <view class="gc-1">
-      <view class="list flex-col">
-        <view v-for="(ele, idx) in datas.relations" :key="ele.id">
-          <view class="r flex-row" @tap="jumpToDetail(ele)">
-            <view class="r1"><img mode :src="ele.img" alt="" /></view>
-            <view class="r2">
-              <view class="n1"
-                ><text>{{ ele.name }}</text></view
-              >
-              <text v-if="ele.tag" class="tag">{{ ele.tag }}</text>
-              <view class="n2">
-                <text class="price1"
-                  >¥<text>{{ ele.show_price }}</text></text
-                >
-                <text v-if="ele.show_price != ele.source_price" class="price2"
-                  >¥<text>{{ ele.source_price }}</text></text
-                >
-              </view>
-              <view class="n3 justify-between">
-                <img v-for="sub in ele.sub_imgs" :key="sub" :src="sub" alt="" />
-              </view>
-            </view>
-          </view>
-          <view v-if="idx < datas.relations.length - 1" class="line"></view>
+  <view class="wrap">
+    <view v-if="list && list.length" class="list">
+      <navigator
+        class="item"
+        v-for="item in list"
+        :key="item.id"
+        :url="`/pages/shop/detail?id=${item.id}`"
+      >
+        <image class="item-img" :src="item.banner"></image>
+        <view class="item-body">
+          <view class="item-name">{{ item.name }}</view>
         </view>
-      </view>
-    </view>
-    <view class="footer">
-      <view class="info">到底啦~ ( ̄▽ ̄)”</view>
-      <view class="contact">联系我们:oushen2022@126.com</view>
+      </navigator>
     </view>
   </view>
 </template>
 <script>
-import api from "@/lib/api/api";
+import login from "@/lib/utils/login";
+import { getShopList } from "@/lib/api/shop";
+
 export default {
-  name: "PageList",
+  name: "PageHome",
   data() {
     return {
-      datas: [],
-      id: "",
+      statusBarHeight: 0, // 自定义导航
+      titleBarHeight: 44, // 自定义导航
+      BarHeight: 0, // 自定义导航
+      userInfo: {},
+      list: [],
+      tabStyle: "",
+      // showTask: false,
     };
   },
-  onLoad(data) {
-    this.id = data.id;
-    this.loadModule(data.id);
+  async onLoad() {
+    this.userInfo = await login.getUserInfo();
+    uni.showLoading({
+      title: "加载中",
+    });
+    this.loadList().then(() => {
+      uni.hideLoading();
+    });
   },
-  // 分享
+  // onShow() {
+  //   // this.getSingInfo();
+  // },
   onShareAppMessage() {
     return {
-      title: "云果国潮,各种绝版大娃抽到飞起!",
+      title: "云果国潮会员中心",
+      imageUrl:
+        "https://yggc.oss-cn-beijing.aliyuncs.com/images/81d939394aea637ac0f6a3026d1a38e6.jpg",
+      path: "/pages/index/index",
     };
   },
-  // 分享
   onShareTimeline() {
     return {
-      title: "云果国潮,各种绝版大娃抽到飞起!",
+      title: "云果国潮会员中心",
+      imageUrl:
+        "https://yggc.oss-cn-beijing.aliyuncs.com/images/81d939394aea637ac0f6a3026d1a38e6.jpg",
+      path: "/pages/index/index",
     };
   },
-  // 下拉刷新
-  onPullDownRefresh() {
-    this.loadModule(this.id, () => {
-      uni.stopPullDownRefresh();
-    });
+  async onPullDownRefresh() {
+    await this.loadList().catch((e) => console.log(e));
+    uni.stopPullDownRefresh();
   },
   methods: {
-    // 获取数据
-    loadModule(id, cb) {
-      api
-        .homeModule(id)
-        .then((data) => {
-          if (data.data) {
-            this.datas = data.data;
-            uni.setNavigationBarTitle({
-              title: this.datas.title,
-            });
-          }
-          if (cb) cb();
-        })
-        .catch(() => {
+    async loadList() {
+      try {
+        const data = await getShopList();
+        if (data.errno == 10000) {
+          this.list = data.data;
+          // this.endTime = data.diff_time;
+          // this.runCd();
+        } else {
           uni.showToast({
             icon: "none",
-            title: "出错啦,请稍后重试",
-            duration: 2e3,
+            title: data.errmsg,
+            duration: 3000,
           });
-          if (cb) cb();
+        }
+      } catch (e) {
+        uni.showToast({
+          icon: "none",
+          title: "出错啦,请稍后重试",
+          duration: 3000,
         });
+      }
     },
-    jumpToDetail(data) {
-      if (data.play_type == 2) {
+
+    // async getSingInfo() {
+    //   if (!this.userInfo.session) {
+    //     this.showTask = true;
+    //     return Promise.reject();
+    //   }
+    //   const data = await getSingInfo(this.userInfo.session);
+    //   this.showTask = !data.is_current_signin;
+    // },
+
+    jumpModuleAll(url) {
+      if (!url) return;
+
+      if (/^https?:\/\//i.test(url)) {
         uni.navigateTo({
-          url: `../detail/pinche?id=${data.id}`,
+          url: `../webview/webview?url=${encodeURIComponent(url)}`,
+        });
+        return;
+      }
+      if (
+        [
+          "/pages/index/index",
+          "/pages/shop/index",
+          "/pages/activity/index",
+          "/pages/my/my",
+        ].includes(url)
+      ) {
+        uni.switchTab({
+          url,
         });
       } else {
         uni.navigateTo({
-          url: `../detail/detail?id=${data.id}`,
+          url,
         });
       }
     },