shish 6 лет назад
Родитель
Сommit
ee658ccfcc
3 измененных файлов с 216 добавлено и 225 удалено
  1. 211 203
      mall/src/components/app-coupon-sel.vue
  2. 1 7
      mall/src/pages/home/user.vue
  3. 4 15
      mall/src/pages/order/buy.vue

+ 211 - 203
mall/src/components/app-coupon-sel.vue

@@ -1,213 +1,221 @@
 <template>
-	<div class="coupon-sel">
-		<block v-if="!$util.isEmpty(shopUser)">
-			<radio-group class="radio-group" name="coupon" @change="checkChange">
-				<!-- 会员优惠 -->
-				<div class="sel-list flex-center-between" v-if="discountArr.indexOf('member') > -1">
-					<div class="sel-tit">
-						<radio value="1" :checked="memberCheck">
-							<span class="dis-pormpt">会员身份({{ shopUser.userAsset.member }}级 {{ shopUser.userAsset.discount }}折)</span>
-						</radio>
-					</div>
-					<!-- <div class="app-price app-size-28">-¥{{ totalDiscountPrice }}</div> -->
-					<div class="app-price app-size-28"></div>
-				</div>
-				<!-- 优惠券优惠 -->
-				<div class="sel-list" v-if="discountArr.indexOf('coupon') > -1">
-					<div class="sel-tit">
-						<radio value="2" >
-							<span class="dis-pormpt">使用优惠券</span>
-						</radio>
-					</div>
-					<div class="coupon-wrap" v-show="selIndex == 2">
-						<div class="coupon-list" v-for="(item, index) in data.coupon" :key="index" @click="couponChange(item, index + 1)">
-							<div class="list-img">
-								<!-- 已过期 -->
-								<template v-if="couponSelInx && couponSelInx == (index + 1)">
-									<img :src="`${constant.imgUrl}/retail/coupon/is-check.png`" alt mode="widthFix" />
-								</template>
-								<template v-else>
-									<img :src="`${constant.imgUrl}/retail/coupon/no-check.png`" alt mode="widthFix" />
-								</template>
-							</div>
-							<!-- 列表 -->
-							<div class="list-det">
-								<div class="list-det-left">
-									<div class="price-wrap">
-										<span>¥</span>
-										<span class="price">{{ item.amount }}</span>
-									</div>
-									<div class="full-reduc app-size-28">满{{ item.miniCost }}可使用</div>
-								</div>
-								<div class="list-det-right">
-									<div class="coupon-message">
-										<div class="app-color-2">优惠券</div>
-										<div>适用:全品类</div>
-										<div>有效至:2020-10-11</div>
-									</div>
-								</div>
-							</div>
-						</div>
-					</div>
-				</div>
-			</radio-group>
-		</block>
-	</div>
+  <div class="coupon-sel">
+    <block v-if="!$util.isEmpty(shopUser)">
+      <radio-group class="radio-group" name="coupon" @change="checkChange">
+        <!-- 会员优惠 -->
+        <div class="sel-list flex-center-between" v-if="discountArr.indexOf('member') > -1">
+          <div class="sel-tit">
+            <radio value="1" :checked="memberCheck">
+              <span
+                class="dis-pormpt"
+              >会员身份({{ shopUser.userAsset.member }}级 {{ shopUser.userAsset.discount }}折)</span>
+            </radio>
+          </div>
+          <!-- <div class="app-price app-size-28">-¥{{ totalDiscountPrice }}</div> -->
+          <div class="app-price app-size-28"></div>
+        </div>
+        <!-- 优惠券优惠 -->
+        <div class="sel-list" v-if="discountArr.indexOf('coupon') > -1">
+          <div class="sel-tit">
+            <radio value="2">
+              <span class="dis-pormpt">使用优惠券</span>
+            </radio>
+          </div>
+          <div class="coupon-wrap" v-show="selIndex == 2">
+            <div
+              class="coupon-list"
+              v-for="(item, index) in data.coupon"
+              :key="index"
+              @click="couponChange(item, index + 1)"
+            >
+              <div class="list-img">
+                <!-- 已过期 -->
+                <template v-if="couponSelInx && couponSelInx == (index + 1)">
+                  <img :src="`${constant.imgUrl}/retail/coupon/is-check.png`" alt mode="widthFix" />
+                </template>
+                <template v-else>
+                  <img :src="`${constant.imgUrl}/retail/coupon/no-check.png`" alt mode="widthFix" />
+                </template>
+              </div>
+              <!-- 列表 -->
+              <div class="list-det">
+                <div class="list-det-left">
+                  <div class="price-wrap">
+                    <span>¥</span>
+                    <span class="price">{{ item.amount }}</span>
+                  </div>
+                  <div class="full-reduc app-size-28">满{{ item.miniCost }}可使用</div>
+                </div>
+                <div class="list-det-right">
+                  <div class="coupon-message">
+                    <div class="app-color-2">优惠券</div>
+                    <div>适用:全品类</div>
+                    <div>有效至:2020-10-11</div>
+                  </div>
+                </div>
+              </div>
+            </div>
+          </div>
+        </div>
+      </radio-group>
+    </block>
+  </div>
 </template>
 
 <script>
-import { mapGetters } from 'vuex'
+import { mapGetters } from "vuex";
 // api
-import { userDiscount } from '@/api/member'
-import { getShopUser } from '@/utils/auth'
+import { userDiscount } from "@/api/member";
+import { getShopUser } from "@/utils/auth";
 export default {
-	name: 'coupon-sel',
-	props: {
-		// 可使用优惠列表
-		// discountArr: {
-		// 	type: Array,
-		// 	default: () => []
-		// }
-		// 金额
-		price: {
-			type: [String, Number],
-			default: 0
-		}
-	},
-	data() {
-		return {
-			constant: this.$constant,
-			memberCheck: false,
-			selIndex: null,
-			couponSelInx: null,
-			couponId: 0,
-			data: {}
-		}
-	},
-	computed: {
-		...mapGetters({ shopUser: 'getShopUser' }),
-		// 可使用优惠列表
-		discountArr() {
-			let newArr = []
-			if (this.$util.isEmpty(this.data)) return newArr
-			if (!this.$util.isEmpty(this.data.member)) {
-				newArr.push('member')
-				this.selIndex = 1
-				this.memberCheck = true
-			}
-			if (!this.$util.isEmpty(this.data.coupon)) {
-				newArr.push('coupon')
-			}
-			return newArr
-		},
-		// 优惠金额
-		totalDiscountPrice() {
-			console.log(this.price)
-			if (this.price) {
-			// console.log(this.$util.floatFormat((this.price - this.price * this.shopUser.userAsset.discount / 10), 1))
-			// return this.$util.floatFormat((this.price - this.price * this.shopUser.userAsset.discount / 10), 1)
-				return ((this.price * 1000000) - (this.price * this.shopUser.userAsset.discount / 10) * 1000000) / 1000000
-			} else {
-				return 0
-			}
-		}
-	},
-	mounted() {
-		// this.init()
-		// getShopUser()
-		// if (this.discountArr.indexOf('member') > -1) {
-		// 	this.selIndex = 1
-		// 	this.memberCheck = true
-		// }
-	},
-	methods: {
-		mInit() {
-			// this._getUserDiscount()
-		},
-		async _getUserDiscount() {
-			let arr = []
-			await userDiscount().then(res => {
-				this.data = res.data
-				arr = this.discountArr
-			})
-			return arr
-		},
-		checkChange(e) {
-			this.selIndex = e.detail.value
-			if (this.selIndex == 1) {
-				this.couponId = 0
-			}
-			this.$emit('checkChange')
-		},
-		// 优惠券选择
-		couponChange(item, index) {
-			this.couponSelInx = this.couponSelInx == index ? null : index
-			this.couponId = item.id
-			this.$emit('couponChange')
-		}
-	}
-}
+  name: "coupon-sel",
+  props: {
+    // 金额
+    price: {
+      type: [String, Number],
+      default: 0
+    }
+  },
+  data() {
+    return {
+      constant: this.$constant,
+      memberCheck: false,
+      selIndex: null,
+      couponSelInx: null,
+      couponId: 0,
+      data: {}
+    };
+  },
+  computed: {
+    ...mapGetters({ shopUser: "getShopUser" }),
+    // 可使用优惠列表
+    discountArr() {
+      let newArr = [];
+      if (this.$util.isEmpty(this.data)) {
+        return newArr;
+      }
+      if (!this.$util.isEmpty(this.data.member)) {
+        newArr.push("member");
+        this.selIndex = 1;
+        this.memberCheck = true;
+      }
+      if (!this.$util.isEmpty(this.data.coupon)) {
+        newArr.push("coupon");
+      }
+      return newArr;
+    },
+    // 优惠金额
+    totalDiscountPrice() {
+      console.log(this.price);
+      if (this.price) {
+        // console.log(this.$util.floatFormat((this.price - this.price * this.shopUser.userAsset.discount / 10), 1))
+        // return this.$util.floatFormat((this.price - this.price * this.shopUser.userAsset.discount / 10), 1)
+        return (
+          (this.price * 1000000 -
+            ((this.price * this.shopUser.userAsset.discount) / 10) * 1000000) /
+          1000000
+        );
+      } else {
+        return 0;
+      }
+    }
+  },
+  mounted() {
+    // this.init()
+    // getShopUser()
+    // if (this.discountArr.indexOf('member') > -1) {
+    // 	this.selIndex = 1
+    // 	this.memberCheck = true
+    // }
+  },
+  methods: {
+    mInit() {
+      // this._getUserDiscount()
+    },
+    async _getUserDiscount() {
+      let arr = [];
+      await userDiscount().then(res => {
+        this.data = res.data;
+        arr = this.discountArr;
+      });
+      return arr;
+    },
+    checkChange(e) {
+      this.selIndex = e.detail.value;
+      if (this.selIndex == 1) {
+        this.couponId = 0;
+      }
+      this.$emit("checkChange");
+    },
+    // 优惠券选择
+    couponChange(item, index) {
+      this.couponSelInx = this.couponSelInx == index ? null : index;
+      this.couponId = item.id;
+      this.$emit("couponChange");
+    }
+  }
+};
 </script>
 
 <style lang="scss" scoped>
-	.sel-list {
-		.sel-tit {
-			@include disFlex(center, flex-start);
-			margin-top: 30px;
-			.dis-pormpt {
-				font-size: 28px;
-				color: $fontColor2;
-				margin-left: 6px;
-			}
-		}
-		&:first-child .sel-tit {
-			margin-top: 0;
-		}
-	}
-	// 优惠券
-	.coupon-wrap {
-		padding-top: 20px;
-		.coupon-list {
-			position: relative;
-			margin-bottom: 6px;
-			.list-det {
-				width: 100%;
-				@include disFlex(center, space-between);
-				position: absolute;
-				top: 0;
-				left: 0;
-				.list-det-left {
-					padding: 20px 0 20px 36px;
-					width: 210px;
-					color: $mainColor;
-					.price-wrap {
-						margin-bottom: 6px;
-						font-size: 26px;
-						.price {
-							font-size: 60px;
-							font-weight: bold;
-							line-height: 1;
-						}
-					}
-				}
-				.list-det-right {
-					width: calc(100% - 280px);
-					margin-left: 22px;
-					@include disFlex(center, space-between);
-					padding: 20px 26px 20px 0;
-					.coupon-message {
-						color: $fontColor3;
-						& > div {
-							margin: 6px 0;
-						}
-					}
-				}
-			}
-		}
-	}
-	// 修改uni-app组件
-	/deep/.uni-radio-input-checked {
-		background-color: $mainColor !important;
-		border-color: $mainColor !important;
-	}
+.sel-list {
+  .sel-tit {
+    @include disFlex(center, flex-start);
+    margin-top: 30px;
+    .dis-pormpt {
+      font-size: 28px;
+      color: $fontColor2;
+      margin-left: 6px;
+    }
+  }
+  &:first-child .sel-tit {
+    margin-top: 0;
+  }
+}
+// 优惠券
+.coupon-wrap {
+  padding-top: 20px;
+  .coupon-list {
+    position: relative;
+    margin-bottom: 6px;
+    .list-det {
+      width: 100%;
+      @include disFlex(center, space-between);
+      position: absolute;
+      top: 0;
+      left: 0;
+      .list-det-left {
+        padding: 20px 0 20px 36px;
+        width: 210px;
+        color: $mainColor;
+        .price-wrap {
+          margin-bottom: 6px;
+          font-size: 26px;
+          .price {
+            font-size: 60px;
+            font-weight: bold;
+            line-height: 1;
+          }
+        }
+      }
+      .list-det-right {
+        width: calc(100% - 280px);
+        margin-left: 22px;
+        @include disFlex(center, space-between);
+        padding: 20px 26px 20px 0;
+        .coupon-message {
+          color: $fontColor3;
+          & > div {
+            margin: 6px 0;
+          }
+        }
+      }
+    }
+  }
+}
+// 修改uni-app组件
+/deep/.uni-radio-input-checked {
+  background-color: $mainColor !important;
+  border-color: $mainColor !important;
+}
 </style>

+ 1 - 7
mall/src/pages/home/user.vue

@@ -21,9 +21,6 @@
                 </div>
               </div>
               <div class="user-level">
-                <!-- <div class="user-level-icon">
-									<img src="" alt />
-                </div>-->
                 <div>成长值 {{ shopUser.userAsset.growth }}/{{ shopUser.userAsset.nextLevelGrowth }}</div>
               </div>
             </div>
@@ -191,12 +188,9 @@ export default {
   methods: {
     init() {
 
-      console.log('cccccc')
-      console.log(this.$constant)
-
       getShopUser().then(res => {
         this.mobile = res.mobile
-        this.subscribe = res.subscribe
+        this.subscribe = parseInt(res.subscribe)
         if (this.option.scan == 1) {
           //没有注册手机号或关注公众号的
           if (this.$util.isEmpty(res.mobile) || res.subscribe == 0) {

+ 4 - 15
mall/src/pages/order/buy.vue

@@ -41,7 +41,7 @@
           <div class="shop-prompt" v-if="!$util.isEmpty(orderShop)" @click="showAlert = true">
             <div>
               <span>{{ `运费(${showDistance}公里)` }}</span>
-              <i class="iconfont iconchangjianwentixiangguanwenti2"></i>
+              <i class="iconfont iconchangjianwentixiangguanwenti2" style="font-size:45rpx;"></i>
             </div>
             <div>¥{{ freightPrice }}</div>
           </div>
@@ -99,7 +99,6 @@ import AppListModule from "@/components/module/app-order-list";
 import AppCouponSel from "@/components/app-coupon-sel";
 import AlertModule from "@/components/plugin/alert";
 const form = require("@/utils/formValidation.js");
-import { calcDistance } from "@/utils/common";
 import { getShopUser } from "@/utils/auth";
 import { getOrderShop } from "@/utils/config";
 import { createOrder } from "@/api/order";
@@ -188,19 +187,9 @@ export default {
 
       getOrderShop().then(() => {
         this.$refs.couponSel._getUserDiscount().then(status => {
+          console.log('discount'+status)
           this.discountArr = status;
-        });
-        if (
-          !this.$util.isEmpty(this.$refs.appDelivery.region) &&
-          this.$refs.appDelivery.region.latitude
-        ) {
-          // 计算距离价格
-          this.freightPrice = calcDistance(
-            this.orderShop.shop,
-            this.$refs.appDelivery.region,
-            this.orderShop.freight
-          );
-        }
+        })
       });
 
       getShopUser();
@@ -253,7 +242,7 @@ export default {
     anonymityChange(e) {
       this.form.anonymity = this.form.anonymity == 1 ? 0 : 1;
     },
-    // 选择地址
+    // 选择地址 
     changeAddress(e) {
       // 计算客户距离和运费
       let lat = this.$refs.appDelivery.region.latitude