Jelajahi Sumber

拉取真实数据、认证鉴权完成

Joe 4 tahun lalu
induk
melakukan
9675ca8506

+ 2 - 2
assets/util/index.js

@@ -1,5 +1,5 @@
 import settings from "../../settings"
 export const getAuthen = () =>{
   const path = window.location.pathname === "/authen" ? "/" : window.location.pathname
-  window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + settings.appId + "&redirect_uri=http%3a%2f%2fwww.onlyfido.top%2fauthen&response_type=code&scope=snsapi_userinfo&state="+ path +"#wechat_redirect"
-}
+  window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + settings.appId + "&redirect_uri=" + settings.url + "%2fauthen&response_type=code&scope=snsapi_userinfo&state="+ path +"#wechat_redirect"
+}

+ 24 - 28
components/ProductList.vue

@@ -7,7 +7,13 @@
       @load="onLoad"
     >
       <div class="shoplist">
-        <nuxt-link class="list-item" v-for="item in list" :key="item.src" to="/point/detail" tag="div">
+        <nuxt-link
+          class="list-item"
+          v-for="item in wareList"
+          :key="item.id"
+          :to="'/point/detail/' + item.id"
+          tag="div"
+        >
           <div class="list-item-left">
             <img :src="item.waresPic" alt="" srcset="" />
           </div>
@@ -19,8 +25,8 @@
               {{ item.waresDetail }}
             </div>
             <div class="item-right-bottom">
-              <span class="price"><span class="icon"></span>40</span>
-              <span class="sold">已兑换 233</span>
+              <span class="price"><span class="icon"></span>{{ item.saleIntegral }}</span>
+              <span class="sold">{{ "库存 " + item.waresCount }}</span>
             </div>
           </div>
         </nuxt-link>
@@ -32,6 +38,7 @@
 <script>
 import Vue from "vue";
 import { PullRefresh, List } from "vant";
+import { mapState, mapActions } from "vuex";
 
 Vue.use(PullRefresh);
 Vue.use(List);
@@ -39,48 +46,37 @@ Vue.use(List);
 export default {
   head() {
     return {
-      title: "订单页",
+      title: "商品列表",
     };
   },
   data() {
     return {
       images: [],
-      list: [],
       loading: false, //加载状态
       finished: false, //是否完成加载
       refreshing: false, //是否正在上拉刷新
     };
   },
-  beforeCreate() {},
-  created() {},
-  beforeMount() {},
   mounted() {
     this.onLoad();
   },
-  beforeUpdate() {},
-  updated() {},
-  beforeDestroy() {},
-  destroyed() {},
+  computed: {
+    ...mapState({
+      wareList: (state) => state.point.wareList,
+    }),
+  },
   methods: {
+    ...mapActions({
+      getWareList: "point/getWareList",
+    }),
     onLoad() {
       var that = this;
-      that.$axios
-        .get("/getIntegralWaresInfoList", {
-          params: {
-            stationId: "1",
-          },
-        })
-        .then((res) => {
-          console.log(res);
-          if (res.data.retCode == 0) {
-            that.list = res.data.data; //追加数据
-            // 加载状态结束
-            that.loading = false;
-            that.finished = true;
-            console.log(that.list);
-          }
-        });
+      this.getWareList().then((res) => {
+        that.loading = false;
+        that.finished = true;
+      });
     },
+
     onRefresh() {
       // 清空列表数据
       that.finished = true;

TEMPAT SAMPAH
dist.zip


+ 1 - 2
layouts/default.vue

@@ -25,8 +25,7 @@ export default {
     //   var s = document.getElementsByTagName("script")[0];
     //   s.parentNode.insertBefore(hm, s);
     // })();
-
-  },
+  }
 }
 </script>t
 

+ 5 - 0
package-lock.json

@@ -6258,6 +6258,11 @@
         "minimist": "^1.2.5"
       }
     },
+    "moment": {
+      "version": "2.29.1",
+      "resolved": "https://registry.npm.taobao.org/moment/download/moment-2.29.1.tgz?cache=0&sync_timestamp=1602337231601&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fmoment%2Fdownload%2Fmoment-2.29.1.tgz",
+      "integrity": "sha1-sr52n6MZQL6e7qZGnAdeNQBvo9M="
+    },
     "move-concurrently": {
       "version": "1.0.1",
       "resolved": "https://registry.npm.taobao.org/move-concurrently/download/move-concurrently-1.0.1.tgz",

+ 1 - 0
package.json

@@ -13,6 +13,7 @@
   "dependencies": {
     "@nuxtjs/axios": "^5.12.4",
     "crypto-js": "^4.0.0",
+    "moment": "^2.29.1",
     "nuxt": "^2.0.0",
     "vant": "^2.4.0",
     "vue-amap": "^0.5.10",

+ 2 - 3
pages/authen.vue

@@ -1,5 +1,5 @@
 <template>
-  <div>123</div>
+  <div>认证中,请稍等</div>
 </template>
 
 <script>
@@ -39,14 +39,13 @@ export default Vue.extend({
           }
         })
         .catch((res) => {
-          alert("catch");
+          alert("网络出错,正在尝试重新加载");
           getAuthen();
         });
     }
   },
   methods: {
     handleGoto() {
-      console.log(this.redirect);
       this.$router.replace({
         path: this.redirect,
       });

+ 49 - 7
pages/point/bill.vue

@@ -2,11 +2,26 @@
   <div class="point-bill">
     <div class="top">
       <span class="icon"></span>
-      <span class="num">136</span>
+      <span class="num">{{pointInfo.points}}</span>
       <span class="text">我的积分</span>
     </div>
 
     <div class="bottom">
+      <div class="item" v-for="item in recordList" :key="item.id">
+        <div class="content">
+          <span class="text">{{item.recordType === '+'? '加油': '兑换商品'}}</span>
+          <span class="amount" :class="item.recordType==='+'?'add':'' ">{{item.recordType + ' ' + item.integral}}</span>
+        </div>
+        <div class="time">{{item.createTime}}</div>
+      </div>
+      <!-- <div class="item">
+        <div class="content">
+          <span class="text">兑换商品</span>
+          <span class="amount">- 10</span>
+        </div>
+        <div class="time">2018/09/20 18:00:00</div>
+      </div>
+      
       <div class="item">
         <div class="content">
           <span class="text">加油</span>
@@ -21,12 +36,22 @@
         </div>
         <div class="time">2018/09/20 18:00:00</div>
       </div>
+
+      <div class="item">
+        <div class="content">
+          <span class="text">加油</span>
+          <span class="amount add">+ 10</span>
+        </div>
+        <div class="time">2018/09/20 18:00:00</div>
+      </div> -->
     </div>
   </div>
 </template>
 
 <script>
 import ProductList from "../../components/ProductList";
+import moment from "moment"
+import { mapState, mapActions } from "vuex"
 export default {
   head() {
     return {
@@ -41,22 +66,40 @@ export default {
       finished: false, // 是否完成加载
       refreshing: false, // 是否正在上拉刷新
       img: "/test/1_a01_class_2@2x.png",
+      recordList:[]
     };
   },
   components: {
     ProductList,
   },
-  beforeCreate() {},
-  created() {},
-  beforeMount() {},
+  computed:{
+    ...mapState({
+      pointInfo:state=>state.point.pointInfo
+    })
+  },
   mounted() {
-    console.log(this);
+    this.getPointsRecordList();
   },
   beforeUpdate() {},
   updated() {},
   beforeDestroy() {},
   destroyed() {},
-  methods: {},
+  methods: {
+    getPointsRecordList(){
+      this.$axios.$get("/getCustomerPointsRecordList",{
+        params:{
+          unionId:this.unionId,
+          stationId:this.stationId
+        }
+      }).then((res)=>{
+        this.recordList = res.data.map((ele)=>{
+          ele.createTime = moment().utc(ele.createTime).format("YYYY.MM.DD HH:mm:ss")
+          return ele
+        })
+      })
+
+    }
+  },
 };
 </script>
 
@@ -155,7 +198,6 @@ export default {
 }
 
 .point-bill .bottom .item .time {
-  width: 2.77rem;
   height: 0.4rem;
   font-size: 0.28rem;
   font-family: PingFangSC-Regular, PingFang SC;

+ 29 - 26
pages/point/detail.vue → pages/point/detail/_id.vue

@@ -1,15 +1,15 @@
 <template>
   <div class="point-detail">
     <div class="good">
-      <img :src="img" alt="" srcset="" />
+      <img :src="ware.waresPic" alt="" srcset="" />
     </div>
     <div class="title">
-      <div class="text">教育读本</div>
+      <div class="text">{{ ware.waresName }}</div>
       <div class="price">
         <span class="icon"></span>
-        <span class="amount">99.00</span>
+        <span class="amount">{{ ware.saleIntegral }}</span>
       </div>
-      <div class="sold">已兑换223</div>
+      <div class="sold">已兑换 {{ ware.waresOutCount }}</div>
     </div>
     <!-- <div class="selected">
       <div class="text">已选</div>
@@ -20,14 +20,18 @@
       <div class="text">- 图文详情 -</div>
     </div> -->
     <div class="buy">
-      <nuxt-link to="/point/pay" tag="button">立刻兑换</nuxt-link>
+      <nuxt-link :to="'/point/pay/' + this.id" tag="button">立刻兑换</nuxt-link>
     </div>
   </div>
 </template>
 
 <script>
-import ProductList from "../../components/ProductList";
+import { mapActions, mapGetters } from 'vuex'
 export default {
+  validate({ params }) {
+    // 必须是number类型
+    return /^\d{1,}$/.test(params.id);
+  },
   head() {
     return {
       title: "积分商品详情页",
@@ -35,28 +39,27 @@ export default {
   },
   data() {
     return {
-      images: [],
-      list: [],
-      loading: false, // 加载状态
-      finished: false, // 是否完成加载
-      refreshing: false, // 是否正在上拉刷新
-      img: "/test/pro.png",
+      ware:{},
+      id:this.$route.params.id
     };
   },
-  components: {
-    ProductList,
-  },
-  beforeCreate() {},
-  created() {},
-  beforeMount() {},
   mounted() {
-    console.log(this);
+    this.getPointInfo();
+    this.init();
+  },
+  computed: {
+    ...mapGetters({
+      findWare: "point/findWare",
+    }),
+  },
+  methods: {
+    ...mapActions({
+      getPointInfo:"point/getPointInfo"
+    }),
+    init(){
+      this.ware = this.findWare(this.id)
+    }
   },
-  beforeUpdate() {},
-  updated() {},
-  beforeDestroy() {},
-  destroyed() {},
-  methods: {},
 };
 </script>
 
@@ -114,7 +117,7 @@ export default {
   display: inline-block;
   width: 0.3rem;
   height: 0.3rem;
-  background: url("../../static/common/a01_jifen@2x.png") no-repeat;
+  background: url("../../../static/common/a01_jifen@2x.png") no-repeat;
   background-size: cover;
   margin-right: 0.1rem;
 }
@@ -166,7 +169,7 @@ export default {
 .point-detail .selected .icon {
   width: 0.42rem;
   height: 0.1rem;
-  background: url("../../static/point/6_d02_more.png") no-repeat 0px 0px;
+  background: url("../../../static/point/6_d02_more.png") no-repeat 0px 0px;
   background-size: cover;
   position: absolute;
   left: 6.3rem;

+ 11 - 35
pages/point/index.vue

@@ -3,7 +3,7 @@
     <div class="background">
       <div class="top">
         <nuxt-link class="text" to="/point/list" tag="h4">我的积分</nuxt-link>
-        <h2 class="point">999</h2>
+        <h2 class="point">{{this.pointInfo.points}}</h2>
         <div class="earn">
           <div>赚积分</div>
         </div>
@@ -36,6 +36,7 @@
 
 <script>
 import ProductList from "../../components/ProductList";
+import { mapState, mapActions } from "vuex"
 export default {
   head() {
     return {
@@ -54,50 +55,25 @@ export default {
   components: {
     ProductList,
   },
+  computed:{
+    ...mapState({
+      pointInfo:state=>state.point.pointInfo
+    })
+  },
   beforeCreate() {},
   created() {},
   beforeMount() {},
   mounted() {
-    // this.$axios.$get("/getCustomerPointsInfo", {
-    //   params: {
-    //     unionId: this.$store.state.anthen.unionId,
-    //     stationId: this.$store.state.anthen.stationId,
-    //   },
-    // }).then((res)=>{
-    //   console.log(res)
-    // });
+    this.getPointInfo();
   },
   beforeUpdate() {},
   updated() {},
   beforeDestroy() {},
   destroyed() {},
   methods: {
-    // onLoad() {
-    //   var that = this;
-    //   that.$axios
-    //     .get("/getIntegralWaresInfoList", {
-    //       params: {
-    //         stationId: "1",
-    //       },
-    //     })
-    //     .then((res) => {
-    //       if (res.data.retCode == 0) {
-    //         that.list = res.data.data; //追加数据
-    //         // 加载状态结束
-    //         that.loading = false;
-    //         that.finished = true;
-    //         console.log(that.list);
-    //       }
-    //     });
-    // },
-    // onRefresh() {
-    //   // 清空列表数据
-    //   that.finished = true;
-    //   // 重新加载数据
-    //   // 将 loading 设置为 true,表示处于加载状态
-    //   that.loading = true;
-    //   that.onLoad();
-    // },
+    ...mapActions({
+      getPointInfo:"point/getPointInfo"
+    })
   },
 };
 </script>

+ 28 - 52
pages/point/list.vue

@@ -1,20 +1,20 @@
 <template>
   <div class="point-list">
-    <div class="order">
+    <div class="order" v-for="item in orderList" :key="item.id">
       <div class="top">
-        <div class="code">订单号 836847623234289</div>
+        <div class="code"> {{"订单号 " + item.integralOrderNo}}</div>
+        <div class="status">已兑换</div>
       </div>
       <div class="middle">
         <div class="imgcon">
-          <img :src="listsrc" alt="" srcset="" />
+          <img :src="item.waresPic" alt="" srcset="" />
         </div>
         <div class="content">
-          <div class="title">水光气垫</div>
-          <div class="desc">15g SPF 50+ PA +++ 自然白</div>
+          <div class="title">{{ item.waresName }}</div>
+          <div class="desc">{{ item.waresDetail }}</div>
           <div class="amount">
             <div>
-              <span class="text">共1件商品 合计 </span><span class="icon"></span
-              ><span>300</span>
+              <span class="text">共{{ item.exchangeNum }}件商品 合计 </span><span class="icon"></span><span>{{item.integral}}</span>
             </div>
           </div>
         </div>
@@ -28,7 +28,7 @@
         </div>
       </div> -->
     </div>
-    <div class="order">
+    <!-- <div class="order">
       <div class="top">
         <div class="code">订单号 836847623234289</div>
         <div class="status">待付款</div>
@@ -49,15 +49,15 @@
         </div>
       </div>
 
-      <!-- <div class="footer">
+      <div class="footer">
         <span class="paytime">付款倒计时:23:59:59</span>
         <div class="paybutton">
           <button class="cancel">取消订单</button>
           <button class="pay">立刻付款</button>
         </div>
-      </div> -->
+      </div>
     </div>
-  </div>
+  </div> -->
 </template>
 
 <script>
@@ -70,54 +70,31 @@ export default {
   },
   data() {
     return {
-      images: [],
-      list: [],
-      loading: false, //加载状态
-      finished: false, //是否完成加载
-      refreshing: false, //是否正在上拉刷新
-      listsrc: "/test/pro.png",
+      orderList:[]
     };
   },
   components: {
     ProductList,
   },
-  beforeCreate() {},
-  created() {},
-  beforeMount() {},
+
   mounted() {
-    console.log(this);
+    this.initOrderList();
   },
-  beforeUpdate() {},
-  updated() {},
-  beforeDestroy() {},
-  destroyed() {},
   methods: {
-    // onLoad() {
-    //   var that = this;
-    //   that.$axios
-    //     .get("/getIntegralWaresInfoList", {
-    //       params: {
-    //         stationId: "1",
-    //       },
-    //     })
-    //     .then((res) => {
-    //       if (res.data.retCode == 0) {
-    //         that.list = res.data.data; //追加数据
-    //         // 加载状态结束
-    //         that.loading = false;
-    //         that.finished = true;
-    //         console.log(that.list);
-    //       }
-    //     });
-    // },
-    // onRefresh() {
-    //   // 清空列表数据
-    //   that.finished = true;
-    //   // 重新加载数据
-    //   // 将 loading 设置为 true,表示处于加载状态
-    //   that.loading = true;
-    //   that.onLoad();
-    // },
+    initOrderList() {
+      this.$axios
+        .$get("/getUserIntegralOrderList", {
+          params: {
+            unionId: this.unionId,
+            stationId: this.stationId,
+          },
+        })
+        .then((res) => {
+          if (res.retCode === 0) {
+            this.orderList = res.data
+          }
+        });
+    },
   },
 };
 </script>
@@ -141,7 +118,6 @@ export default {
   border-bottom: 0.01rem solid #e0e0e0;
 }
 .point-list .order .top .code {
-  width: 3.44rem;
   height: 0.4rem;
   font-size: 0.28rem;
   font-family: PingFangSC-Regular, PingFang SC;

+ 67 - 63
pages/point/pay.vue → pages/point/pay/_id.vue

@@ -2,37 +2,43 @@
   <div class="point-pay">
     <div class="product">
       <div class="img">
-        <img :src="img" alt="" />
+        <img :src="ware.waresPic" alt="" />
       </div>
       <div class="content">
-        <div class="title">教育读本</div>
+        <div class="title">{{ware.waresName}}</div>
         <div class="amount">
-          <span class="text">积分 99</span> <span class="num">x 1</span>
+          <span class="text">积分 {{ware.saleIntegral}}</span> <span class="num">x 1</span>
         </div>
       </div>
     </div>
     <div class="have">
       <span class="icon1"></span>
-      <span class="text">当前可用积分余额 100</span>
+      <span class="text">当前可用积分余额 {{pointInfo.points}}</span>
       <span class="icon2"></span>
     </div>
     <div class="total">
-      <div class="text">合计:<span class="num">99积分</span></div>
-      <nuxt-link to="/point/success" tag="button">提交订单</nuxt-link>
+      <div class="text">合计:<span class="num">{{ware.saleIntegral}}积分</span></div>
+      <button @click="pay">提交订单</button>
     </div>
   </div>
 </template>
 
 <script>
-import ProductList from "../../components/ProductList";
+import ProductList from "../../../components/ProductList";
+import { mapState, mapGetters, mapActions } from "vuex";
+
 export default {
+  validate({ params }) {
+    return /^\d{1,}$/.test(params.id);
+  },
   head() {
     return {
-      title: "积分支付",
+      title: "积分兑换确认",
     };
   },
   data() {
     return {
+      id: this.$route.params.id,
       images: [],
       list: [],
       loading: false, //加载状态
@@ -41,46 +47,45 @@ export default {
       img: "/test/pro.png",
     };
   },
+  computed: {
+    ...mapState({
+      pointInfo: (state) => state.point.pointInfo,
+      userInfo:(state) => state.authen.userInfo
+    }),
+    ...mapGetters({
+      userInfo: "authen/userInfo",
+      findWare: "point/findWare",
+    }),
+    ware() {
+      console.log("ware");
+      return this.findWare(this.id)
+    }
+  },
   components: {
     ProductList,
   },
-  beforeCreate() {},
-  created() {},
-  beforeMount() {},
   mounted() {
     console.log(this);
   },
-  beforeUpdate() {},
-  updated() {},
-  beforeDestroy() {},
-  destroyed() {},
   methods: {
-    // onLoad() {
-    //   var that = this;
-    //   that.$axios
-    //     .get("/getIntegralWaresInfoList", {
-    //       params: {
-    //         stationId: "1",
-    //       },
-    //     })
-    //     .then((res) => {
-    //       if (res.data.retCode == 0) {
-    //         that.list = res.data.data; //追加数据
-    //         // 加载状态结束
-    //         that.loading = false;
-    //         that.finished = true;
-    //         console.log(that.list);
-    //       }
-    //     });
-    // },
-    // onRefresh() {
-    //   // 清空列表数据
-    //   that.finished = true;
-    //   // 重新加载数据
-    //   // 将 loading 设置为 true,表示处于加载状态
-    //   that.loading = true;
-    //   that.onLoad();
-    // },
+    pay(){
+      this.$axios.$post("insertIntegralOrder",{
+        "waresId":this.id,
+        "waresName":this.ware.waresName, 
+        "openId":this.openId,
+        "unionId":this.unionId,
+        "customerName":this.userInfo.nickname,
+        "exchangeNum":1,
+        "integral":this.ware.saleIntegral,
+        "stationId":this.stationId
+      }).then((res)=>{
+        this.$router.push({
+          path:"/point/success"
+        })
+      })
+      
+    }
+
   },
 };
 </script>
@@ -152,7 +157,7 @@ export default {
   display: inline-block;
   width: 0.4rem;
   height: 0.35rem;
-  background: url("../../static/point/jifen@2x.png") no-repeat 0 0;
+  background: url("../../../static/point/jifen@2x.png") no-repeat 0 0;
   background-size: 100% 100%;
   position: absolute;
   top: 0.39rem;
@@ -172,7 +177,7 @@ export default {
   display: inline-block;
   width: 0.36rem;
   height: 0.36rem;
-  background: url("../../static/point/xuanzhong@2x.png") no-repeat 0 0;
+  background: url("../../../static/point/xuanzhong@2x.png") no-repeat 0 0;
   background-size: 100% 100%;
   position: absolute;
   right: 0.36rem;
@@ -185,31 +190,30 @@ export default {
   opacity: 0.95;
   position: fixed;
   bottom: 0;
-  left:0;
+  left: 0;
   right: 0;
   display: flex;
-  justify-content:flex-end;
+  justify-content: flex-end;
   box-sizing: border-box;
-  padding:.4rem;
-  align-items:center;
+  padding: 0.4rem;
+  align-items: center;
 }
 
-.point-pay .total .text{
-font-size: 0.28rem;
-font-family: PingFangSC-Regular, PingFang SC;
-font-weight: 400;
-color: #111111;
-line-height: 0.4rem;
-
+.point-pay .total .text {
+  font-size: 0.28rem;
+  font-family: PingFangSC-Regular, PingFang SC;
+  font-weight: 400;
+  color: #111111;
+  line-height: 0.4rem;
 }
-.point-pay .total .text .num{
-width: 1.17rem;
-height: 0.62rem;
-font-size: 0.44rem;
-font-family: PingFangSC-Regular, PingFang SC;
-font-weight: 400;
-color: #111111;
-line-height: 0.62rem;
+.point-pay .total .text .num {
+  width: 1.17rem;
+  height: 0.62rem;
+  font-size: 0.44rem;
+  font-family: PingFangSC-Regular, PingFang SC;
+  font-weight: 400;
+  color: #111111;
+  line-height: 0.62rem;
 }
 .point-pay .total button {
   border: none;
@@ -225,6 +229,6 @@ line-height: 0.62rem;
   font-weight: 400;
   color: #ffffff;
   line-height: 0.4rem;
-  margin-left:0.2rem;
+  margin-left: 0.2rem;
 }
 </style>

+ 9 - 9
pages/point/success.vue

@@ -41,15 +41,15 @@ export default {
   created() {},
   beforeMount() {},
   mounted() {
-    console.log("测试一下微信jdk");
-    wx.config({
-      debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
-      appId: 'wxc8189d3b3a7283e0', // 必填,公众号的唯一标识
-      timestamp: 11, // 必填,生成签名的时间戳
-      nonceStr: '', // 必填,生成签名的随机串
-      signature: '',// 必填,签名
-      jsApiList: [] // 必填,需要使用的JS接口列表
-    });
+    // console.log("测试一下微信jdk");
+    // wx.config({
+    //   debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+    //   appId: 'wxc8189d3b3a7283e0', // 必填,公众号的唯一标识
+    //   timestamp: 11, // 必填,生成签名的时间戳
+    //   nonceStr: '', // 必填,生成签名的随机串
+    //   signature: '',// 必填,签名
+    //   jsApiList: [] // 必填,需要使用的JS接口列表
+    // });
   },
   beforeUpdate() {},
   updated() {},

+ 3 - 1
settings.js

@@ -1,4 +1,6 @@
 export default {
   appId:"wxc8189d3b3a7283e0",
-  stationId:1
+  stationId:1,
+  // url:"http://www.onlyfido.top"
+  url:"http://www.huijy.net/"
 }

+ 16 - 6
store/authen.js

@@ -17,19 +17,19 @@ export const getters = {
     if(!state.openIdOrigin){
       getAuthen()
     }
-    return state.openId
+    return state.openIdOrigin
   },
   accessToken:(state)=>{
-    if(!state.accessToken){
+    if(!state.accessTokenOrigin){
       getAuthen()
     }
     return state.accessToken
   },
   unionId:(state)=>{
-    if(!state.unionId){
+    if(!state.unionIdOrigin){
       getAuthen()
     }
-    return state.unionId
+    return state.unionIdOrigin
   },
   userInfo:(state)=>state.userInfoOrigin,
   stationId:(state)=>state.stationIdOrigin,
@@ -47,6 +47,7 @@ export const mutations = {
     state.unionIdOrigin = unionId
   },
   setUserInfo(state, userInfo) {
+    console.log("setUserInfo",userInfo);
     state.userInfoOrigin = userInfo
   }
 }
@@ -56,14 +57,23 @@ export const actions = {
     commit("setOpenId", info.openId)
     commit("setAccessToken", info.accessToken)
     commit("setUnionId", info.unionId)
-    this.$axios.$get("/getGzhUserInfo", {
+    return this.$axios.$get("/getGzhUserInfo", {
       params: {
         openId: info.openId,
-        stationId: state.stationId
+        stationId: state.stationIdOrigin
       }
     }).then((res) => {
       if (res.retCode === 0) {
         commit("setUserInfo", res.data)
+        this.$axios.$post("/addAppUserInfo",{
+          userType: "1",
+          openId: info.openId,
+          unionId: info.unionId,
+          stationId: state.stationIdOrigin, //油站Id
+          blogNickName: res.data.nickname,
+          sexFlag: res.data.sex === 1 ? 'M' : 'F',
+          blogProfilePhoto: res.data.headimgurl
+        })
       }
     })
   }

+ 60 - 0
store/point.js

@@ -0,0 +1,60 @@
+import settings from '../settings'
+import { getAuthen } from '../assets/util'
+
+
+
+// 带Origin后缀的通过getter获取
+export const state = () => ({
+  pointInfo: {},
+  wareList: [],
+  wareItemOrigin: undefined,
+})
+
+export const getters = {
+  findWare: (state) => id => state.wareList.find((item)=>{
+    return item.id.toString() === id.toString();
+  })
+}
+
+export const mutations = {
+  setPointInfo(state, pointInfo) {
+    state.pointInfo = pointInfo
+  },
+  setWareList(state, wareList){
+    state.wareList = wareList
+  }
+}
+
+export const actions = {
+  getPointInfo({ commit, state, rootGetters }) {
+    return this.$axios.$get("/getCustomerPointsInfo", {
+      params: {
+        unionId: rootGetters["authen/unionId"],
+        stationId: rootGetters["authen/stationId"],
+      },
+    }).then((res) => {
+      if (res.retCode === 0) {
+        commit("setPointInfo", res.data);
+      }
+    });
+  },
+  getWareList({ commit, state, rootGetters }) {
+    return this.$axios
+      .$get("/getIntegralWaresInfoList", {
+        params: {
+          stationId: rootGetters["authen/stationId"],
+        },
+      })
+      .then((res) => {
+        if (res.retCode == 0) {
+          commit("setWareList", res.data)
+        }
+      });
+  },
+  getPointsRecordList({ commit, state, rootGetters },params){
+    return this.$axios.$get("/getCustomerPointsInfogetCustomerPointsRecordList",{
+      params
+    })
+  }
+  
+}