guhongwei 2 anos atrás
pai
commit
a66bcacecf
2 arquivos alterados com 452 adições e 17 exclusões
  1. 424 0
      common/weapp-qrcode.js
  2. 28 17
      pagesHome/shop/index.vue

Diferenças do arquivo suprimidas por serem muito extensas
+ 424 - 0
common/weapp-qrcode.js


+ 28 - 17
pagesHome/shop/index.vue

@@ -10,8 +10,7 @@
 						<scroll-view scroll-y="true" class="scroll-view">
 							<view class="list-scroll-view">
 								<view class="list" v-for="(item,index) in shoplist" :key="index">
-									<image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''"
-										mode=""></image>
+									<image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''" mode=""></image>
 									<view class="name">
 										{{item.name}}
 									</view>
@@ -37,20 +36,17 @@
 						<scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage">
 							<view class="list-scroll-view">
 								<view class="second_1">
-									<view :class="['list',condActive==index?'activeList':'']"
-										v-for="(item,index) in condList" :key="index" @tap="toCond(index,item)">
+									<view :class="['list',condActive==index?'activeList':'']" v-for="(item,index) in condList" :key="index" @tap="toCond(index,item)">
 										<view class="name">
 											{{item.name}}
 										</view>
 										<view class="icon">
 											<view class="icon_1">
-												<text :class="['iconfont',item.shangActive]"
-													v-if="condActive==index&&shang=='1'"></text>
+												<text :class="['iconfont',item.shangActive]" v-if="condActive==index&&shang=='1'"></text>
 												<text :class="['iconfont',item.shang]" v-else></text>
 											</view>
 											<view class="icon_1">
-												<text :class="['iconfont', item.xiaActive]"
-													v-if="condActive==index&&xia=='-1'"></text>
+												<text :class="['iconfont', item.xiaActive]" v-if="condActive==index&&xia=='-1'"></text>
 												<text :class="['iconfont', item.xia]" v-else></text>
 											</view>
 										</view>
@@ -58,8 +54,7 @@
 								</view>
 								<view class="second_2">
 									<view class="list" v-for="(item,index) in list" :key="index">
-										<image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''"
-											mode=""></image>
+										<image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''" mode=""></image>
 										<view class="sale" v-if="item.is_sale==true">
 											<text>已售尽</text>
 										</view>
@@ -104,9 +99,10 @@
 						<view class="second_2">
 							<view class="second_2_bor" @tap="saveQrcode">
 								<!-- <image class="image" :src="info.qrcode&&info.qrcode.length>0?info.qrcode[0].url:''" mode=""></image> -->
-								<tki-qrcode cid="qrcode1" ref="qrcode" :val="val" :size="size" :unit="unit"
+								<!-- <tki-qrcode cid="qrcode1" ref="qrcode" :val="val" :size="size" :unit="unit"
 									:background="background" :foreground="foreground" :pdground="pdground"
-									:onval="onval" :loadMake="loadMake" :usingComponents="true" @result="qrR" />
+									:onval="onval" :loadMake="loadMake" :usingComponents="true" @result="qrR" /> -->
+								<canvas class="qrcode" canvas-id="myQrcode"></canvas>
 							</view>
 							<view class="txt">
 								店铺二维码
@@ -134,11 +130,10 @@
 </template>
 
 <script>
-	import tkiQrcode from "@/components/tki-qrcode/tki-qrcode.vue"
+	// import tkiQrcode from "@/components/tki-qrcode/tki-qrcode.vue"
+	import QRCode from '@/common/weapp-qrcode.js'
 	export default {
-		components: {
-			tkiQrcode
-		},
+		components: {},
 		data() {
 			return {
 				val: '', // 要生成的二维码值
@@ -217,7 +212,6 @@
 		onLoad: async function(e) {
 			const that = this;
 			that.$set(that, `id`, e.id || '');
-			that.$set(that, `val`, `https://broadcast.waityou24.cn/shopinfo?id=${e.id}`);
 			await that.watchLogin();
 			await that.search();
 			await that.searchOther();
@@ -260,6 +254,8 @@
 					that.searchShopMarket();
 					// 查询全部商品
 					that.searchAll();
+					// 创建二维码
+					that.createQrcode(that.info);
 				}
 			},
 			// 查询店铺商品
@@ -294,6 +290,21 @@
 					});
 				}
 			},
+			// 创建二维码
+			createQrcode(e) {
+				// console.log(e);
+				const that = this;
+				const url = `${that.$config.serverUrl}/shopinfo?id=${e._id}`;
+				var qrcode = new QRCode(`myQrcode`, {
+					text: url,
+					width: 110,
+					height: 110,
+					padding: 3,
+					colorDark: "#000000",
+					colorLight: "#ffffff",
+					correctLevel: QRCode.CorrectLevel.L,
+				});
+			},
 			// 购买
 			toBuy(item) {
 				if (item && item._id) {