瀏覽代碼

feat:商品列表 商品详情 提交订单 添加收货地址

DaMowang 3 年之前
父節點
當前提交
5503687874

+ 18 - 9
src/components/goodsList.vue

@@ -1,16 +1,16 @@
 <template>
     <view class="product-list">
-        <view class="product" v-for="(i, s) in productList" :key="s" @click="NavToGoodsDetail(i.goodsId,i.type)">
+        <view class="product" v-for="(i, s) in productList" :key="s" @click="NavToGoodsDetail(i.id,i.type)">
             <view class="image-view">
                 <image class="product-image" :src="i.goodsThumbnailUrl"></image>
             </view>
-            <view :class="['product-title', 'ellipsis' + long]">{{ i.goodsName }}</view>
+            <view :class="['product-title', 'ellipsis' + long]">{{ i.goods.goods_name }}</view>
             <view class="product-price">
-                <text class="product-price-original"><text class="product-unit">¥</text>{{ i.price }}</text>
+                <text class="product-price-original"><text class="product-unit">¥</text>{{ type == 2 ? i.trade_price : i.cost_price }}</text>
                 <!-- <text class="product-price-favour">¥{{i.originalPrice}}</text> -->
                 <!-- <text class="product-tip">{{i.tip}}</text> -->
             </view>
-            <view class="product-txt">{{ i.fanIntegral }}</view>
+            <view class="product-txt">{{ i.trade_give_num }}</view>
         </view>
         <view class='fz_w_text mar_t20 mar_b20'>茶,让生活更美好!</view>
     </view>
@@ -29,6 +29,10 @@ export default {
             type: String,
             default: "",
         },
+        type: {
+            type: String,
+            default: "3",
+        },
     },
     data() {
         return {
@@ -39,17 +43,22 @@ export default {
         this.loadData();
     },
     methods: {
-        loadData() {
-            post(this.url).then((res) => {
-                if (res.status == 200) {
-                    this.productList = res.goods;
+        loadData(page) {
+            post("goods/goodsList",{
+                type: this.type,
+                page: page ? page : 1
+            }).then((res) => {
+                if(page == 1) this.productList = []
+                if (res.code === 0) {
+                    console.log(res);
+                    this.productList = [...this.productList,...res.data.data]
                 }
             });
         },
         // 跳转到商品详情页
         NavToGoodsDetail(id,type){
             uni.navigateTo({
-                url:'/pages/product/p_details?id=' + id + '&type=' + type
+                url:'/pages/product/p_details?id=' + id + '&type=' + this.type
             })
         },
     },

+ 180 - 0
src/components/goodsLista.vue

@@ -0,0 +1,180 @@
+<template>
+	<view>
+		<view class="feng_flow">
+			<view class="flow_block">
+				<view class="flow_item" v-for="(i, i1) in lists1" :key="i1">
+					<image :src="Url" mode="widthFix" style="width: 100%;"></image>
+					<view class="flow_item_con" v-if="false">
+						<view class="flow_item_title">¥{{ type == 2 ? a.trade_price : a.cost_price }}</view>
+						<view class="flow_item_des">{{ i.trade_give_num }}</view>
+					</view>
+				</view>
+			</view>
+			<view class="flow_block">
+				<view class="flow_item" v-for="(a, i2) in lists2" :key="i2">
+					<image :src="Url" mode="widthFix" style="width: 100%;"></image>
+					<view class="flow_item_con" v-if="false">
+						<view class="flow_item_title">¥{{ type == 2 ? a.trade_price : a.cost_price }}</view>
+						<view class="flow_item_des">{{ a.trade_give_num }}</view>
+					</view>
+				</view>
+			</view>
+		</view>
+		<view class="feng_flow" style="display: none;">
+			<view class="flow_block">
+				<view class="flow_item" v-for="(data,da_i) in dataLists" :key="da_i">
+					<image :src="data.zipurl" @error="imgError" @load="imgLoad" :id="da_i" mode="widthFix" style="width:100%;"></image>
+				</view>
+			</view>
+			<view class="flow_block"></view>
+		</view>
+	</view>
+</template>
+<script>
+import { get, post } from "@/request/api.js";
+export default {
+	name: 'fengFlow',
+    props: {
+        long: {
+            type: Number,
+            default: 2,
+        },
+        type: {
+            type: String,
+            default: "3",
+        },
+    },
+	data() {
+		return {
+			dataLists: [],
+			lists1: [],
+			lists2: [],
+			list1Height: 0,
+			list2Height: 0,
+			tmp_data: [],
+			loaded: [], //图片加载成功数组
+			loadErr: [], //图片加载失败数组
+			showLoad: false,
+
+            Url: "https://teaclub.oss-cn-chengdu.aliyuncs.com/ShuZiTea/goods/20221008/bba4ab41-ec1a-462f-8d3c-5b36d81a3a1a.jpg" 
+		};
+	},
+	onLoad() {},
+	methods: {
+		// 获取作品列表
+		loadData(page) {
+            post("goods/goodsList",{
+                type: this.type,
+                page: page ? page : 1
+            }).then((res) => {
+                if(page == 1) this.dataLists  = []
+                if (res.code === 0) {
+                    this.dataLists  = [...this.dataLists ,...res.data.data]
+                }
+            });
+		},
+
+		//处理数据
+		refresData() {
+			this.hideLoadFlag()
+			if (this.loaded.length + this.loadErr.length < this.tmp_data.length) return;
+			const that = this
+			this.tmp_data.map((da, di) => {
+				if (that.list1Height > that.list2Height) {
+					that.list2Height += da.img_height
+					that.lists2.push(da)
+				} else {
+					that.list1Height += da.img_height
+					that.lists1.push(da)
+				}
+
+			})
+		},
+		//图片加载完成补齐数据
+		imgLoad(e) {
+			this.loaded.push(e.target.id)
+			//存储数据
+			this.tmp_data[e.target.id]['img_width'] = e.detail.width
+			this.tmp_data[e.target.id]['img_height'] = e.detail.height
+
+		},
+		//图片未加载成功触发
+		imgError(e) {
+			this.loadErr.push(e.target.id)
+		},
+		showLoadFlag() {
+			if (!this.showLoad) {
+				this.showLoad = true
+				uni.showLoading({
+					title: 'loading...',
+					mask: 'none'
+				})
+			}
+		},
+		hideLoadFlag() {
+			if (this.showLoad) {
+				uni.hideLoading();
+				this.showLoad = false;
+			}
+		},
+	},
+    created () {
+		this.loadData();
+    },
+	mounted() {
+		const that = this
+		that.tmp_data = that.dataLists
+		that.showLoadFlag()
+	},
+	watch: {
+		dataLists() {
+			this.loaded = []
+			this.loadErr = []
+			this.tmp_data = this.dataLists
+			this.showLoadFlag()
+		},
+		loaded() {
+			//最后一个加载完成负责刷新数据
+			this.refresData()
+		},
+		loadErr() {
+			//最后一个加载完成负责刷新数据
+			this.refresData()
+		}
+	}
+};
+</script>
+<style>
+.feng_flow {
+	display: flex;
+	padding: 15upx;
+}
+
+.flow_block {
+	display: flex;
+	flex: 1;
+	flex-direction: column;
+}
+
+.flow_item {
+	margin: 15upx;
+	border-radius: 20upx;
+	background: #f4f4f4;
+	overflow: hidden;
+}
+
+.flow_item_con {
+	padding: 10upx 20upx 20upx;
+}
+
+.flow_item_title {
+	position: relative;
+	font-size: 32upx;
+	font-weight: 700;
+	margin-bottom: 5upx;
+}
+
+.flow_item_des {
+	font-size: 24upx;
+}
+</style>

+ 1 - 1
src/manifest.json

@@ -87,7 +87,7 @@
         "template" : "index.html",
         "router" : {
             "mode" : "history",
-            "base" : "/h5/"
+            "base" : ""
         },
         "optimization" : {
             "treeShaking" : {

+ 6 - 0
src/pages.json

@@ -54,6 +54,12 @@
 				"navigationBarTitleText": "订单购买"
 			}
 		},
+		{
+			"path": "pages/xghc-addrress/userAddress",
+			"style": {
+				"navigationBarTitleText": "收货地址"
+			}
+		},
 		{
 			"path": "pages/protocol/index",
 			"style": {

+ 2 - 2
src/pages/index/index.vue

@@ -48,7 +48,7 @@
         </view>
         <view class="list_bar">
             <div class="tit">猜你喜欢</div>
-            <goodslist :url="goodslistUrl" :long="1" />
+            <goodslist :long="1" type="1" />
         </view>
     </div>
 </template>
@@ -70,7 +70,7 @@ export default {
             not_list: [], // 公告列表
             area_list: [], // 金刚区
             spc_list: [], //活动列表
-            goodslistUrl: "ShuZiTeaYW/shop/getGoodsLikeByUserId", //首页商品列表
+            // goodslistUrl: "ShuZiTeaYW/shop/getGoodsLikeByUserId", //首页商品列表
         };
     },
     onLoad(option) {

+ 0 - 15
src/pages/my/login.vue

@@ -168,21 +168,6 @@ export default {
 };
 </script>
 <style scoped lang='scss'>
-@font-face {
-    font-family: 'webfont'; //欢迎登录单仁教育 标题文字字体
-    font-display: swap;
-    src: url('//at.alicdn.com/t/webfont_8g34jazbwuj.eot');
-    /* IE9*/
-    src: url('//at.alicdn.com/t/webfont_8g34jazbwuj.eot?#iefix') format('embedded-opentype'),
-        /* IE6-IE8 */
-        url('//at.alicdn.com/t/webfont_8g34jazbwuj.woff2') format('woff2'),
-        url('//at.alicdn.com/t/webfont_8g34jazbwuj.woff') format('woff'),
-        /* chrome、firefox */
-        url('//at.alicdn.com/t/webfont_8g34jazbwuj.ttf') format('truetype'),
-        /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/
-        url('//at.alicdn.com/t/webfont_8g34jazbwuj.svg#思源黑体-粗') format('svg');
-    /* iOS 4.1- */
-}
 
 .login {
     text-align: center;

+ 107 - 104
src/pages/product/p_details.vue

@@ -1,7 +1,7 @@
 <template>
 	<view class="container">
 		<!-- 轮播图 -->
-		<swiper-banner
+		<!-- <swiper-banner
 			imgScale="25:17"
 			:imgArr='detail.goodsPlayImage'
 			:duration="1000"
@@ -11,34 +11,34 @@
 			:indicator-dots="true"
 			indicator-active-color="#12B280"
 			indicator-color="rgba(255, 255, 255, .82)" 
-		></swiper-banner>
+		></swiper-banner> -->
 		<!-- 轮播图-end -->
 		
 		<!-- 价格信息栏 -->
-		<view class="price_info flex_r flex_ac flex_jb">
+		<!-- <view class="price_info flex_r flex_ac flex_jb">
 			<view class="price" :class="type == 2 ? 'samll' : ''"><text v-if="type != 2">¥</text>{{type != 2 ? detail.price : detail.pfCombination}}</view>
 			<view class="price_span flex_r flex_ac flex_je">
 				<view class="triangle"></view>
 				<view class="span_conten flex_r flex_ac flex_jc">{{type == 1 ? '零售专区' : type == 2 ? '批发专区' : type == 3 ? '合伙人套餐' : type == 4 ? 'CHA专区' : '今日值得买'}}</view>
 			</view>
-		</view>
+		</view> -->
 		<!-- 价格信息栏-end -->
 		
 		<!-- 标题信息栏 -->
-		<view class="title_info">
+		<!-- <view class="title_info">
 			<view class="goods_name">{{ type != 3 ? detail.goodsName : detail.title}}</view>
 			<view class="goods_subName">{{detail.goodsMsg}}</view>
-		</view>
+		</view> -->
 		<!-- 标题信息栏-end -->
 		
 		<!-- 产品简介 -->
-		<view class="brief mar_t20">
+		<!-- <view class="brief mar_t20">
 			<view class="brief_title flex_r flex_ac">产品简介</view>
 			<view class="brief_con">
 				<jyfParser :html="detail.goodsDesc" ref="jyf"></jyfParser>
 				<image :lazy-load="true" style="width: 100%;display: block;" v-for="(item,index) in detail.goodsDetailesImage" :key="index" :src="item" mode="widthFix"></image>
 			</view>
-		</view>
+		</view> -->
 		<!-- 产品简介-end -->
 		
 		<!-- 底部导航组件 -->
@@ -47,7 +47,7 @@
 		</view>
 		<!-- 底部导航组件-end -->
 		<!-- 授权 -->
-		<authorize-module v-if="showAuth" :shopInfo="shopInfo" @authSuccess="onAuthSuccess" @onGotUserInfo="onGotUserInfo" ></authorize-module>
+		<!-- <authorize-module v-if="showAuth" :shopInfo="shopInfo" @authSuccess="onAuthSuccess" @onGotUserInfo="onGotUserInfo" ></authorize-module> -->
 		<!-- 授权-end -->
 		
 		<!-- 购买或加入购物车弹窗 -->
@@ -57,22 +57,22 @@
 					<image class="close_img" src="/static/close.png" @tap="closeBtn" mode=""></image>
 				</view>
 				<view class="goods_info flex_r">
-					<image class="goods_img" :src="detail.goodsPlayImage[0]" mode=""></image>
+					<image class="goods_img" :src="detail.goods.original_img" mode=""></image>
 					<view class="goods_con flex_c flex_jb">
-						<view class="shop_names">{{ type != 3 ? detail.goodsName : detail.title}}</view>
-						<view class="goods_msg">{{type == 2 ? detail.pfCombination : '¥' + detail.price}}</view>
-						<view class="num_con flex_r flex_je" v-if="type != 3">
+						<view class="shop_names">{{detail.goods.goods_name}}</view>
+						<!-- <view class="goods_msg">{{type == 2 ? detail.pfCombination : '¥' + detail.price}}</view> -->
+						<view class="num_con flex_r flex_je">
 							<uni-number-box :min="1" @change="bindChange" :value="buyNum"></uni-number-box>
 						</view>
 					</view>
 				</view>
 				<view class="goods_option flex_r flex_ac flex_jc" v-if="type == 2">
-					<view class="goods_raido flex_r flex_ac" @tap="setWay(2)">
-						<view class="raido_img" :class="pfway == 2 ? 'raido_box' : ''"></view>
+					<view class="goods_raido flex_r flex_ac" @tap="setWay('1')">
+						<view class="raido_img" :class="pfway == '1' ? 'raido_box' : ''"></view>
 						<view class="raido_text">申请寄售</view>
 					</view>
-					<view class="goods_raido flex_r flex_ac" @tap="setWay(1)">
-						<view class="raido_img" :class="pfway == 1 ? 'raido_box' : ''"></view>
+					<view class="goods_raido flex_r flex_ac" @tap="setWay('0')">
+						<view class="raido_img" :class="pfway == '0' ? 'raido_box' : ''"></view>
 						<view class="raido_text">发货邮寄</view>
 					</view>
 				</view>
@@ -144,64 +144,59 @@ import authorizeModule from '@/components/authorize-module/index'
 				detail:'' ,// 商品详情
 				checked:false, //是否选中协议
 				buyNum: 1 ,//购买数量
-				pfway:2 ,// 批发
-				showAuth:false
+				pfway: "0" ,// 批发
+				showAuth:false,
+
+				userinfo: {},
+				goodsDa: {},
 			};
 		},
 		onLoad:function(e){
-			this.type=e.type
-			if(e.type == 3){
-				this.id = e.id
-			}else{
-				this.goodsId = e.id
-			}
-			if(e.type == 3 || e.type == 2 || e.type == 4 || e.type == 7){
-				this.buttonGroup.shift()
-			}
-			//推荐人ID
-			if (e.agentId) {
-			    app.globalData.agentId = e.agentId;
-			}
-			if (e && e.scene){
-			    var scene = decodeURIComponent(e.scene).split("&");
-			    if (scene.length > 0) {
-			        var agentId = scene[0].split(":");
-			        app.globalData.agentId = agentId[1] && agentId[1] != '' ? agentId[1] : app.globalData.agentId;
-			        var goodsId = scene[1].split(":");
-			        this.goodsId = goodsId[1] && goodsId[1] != '' ? goodsId[1] : ''
-			    }
-			}
-			this.loadData()
+			this.goodsDa = e;
+			this.userinfo = uni.getStorageSync('userinfo');
+			// this.type=e.type
+			// if(e.type == 3){
+			// 	this.id = e.id
+			// }else{
+			// 	this.goodsId = e.id
+			// }
+			// if(e.type == 3 || e.type == 2 || e.type == 4 || e.type == 7){
+			// 	this.buttonGroup.shift()
+			// }
+			// //推荐人ID
+			// if (e.agentId) {
+			//     app.globalData.agentId = e.agentId;
+			// }
+			// if (e && e.scene){
+			//     var scene = decodeURIComponent(e.scene).split("&");
+			//     if (scene.length > 0) {
+			//         var agentId = scene[0].split(":");
+			//         app.globalData.agentId = agentId[1] && agentId[1] != '' ? agentId[1] : app.globalData.agentId;
+			//         var goodsId = scene[1].split(":");
+			//         this.goodsId = goodsId[1] && goodsId[1] != '' ? goodsId[1] : ''
+			//     }
+			// }
+			this.loadData(e)
 		},
 		onShow:function(){
-			let that = this;
-			let userId = app.globalData.systemUserInfo && app.globalData.systemUserInfo.userId ? app.globalData.systemUserInfo.userId : '';
-			if (!userId || userId == '' || userId==undefined) {
-				that.showAuth=true
-				appEv.authorizeUserInfo(res=>{
-					if(res){
-						that.shopInfo=app.globalData.shopInfo
-						that.showAuth=false
-					}
-				})
-			}
+			// let that = this;
+			// let userId = app.globalData.systemUserInfo && app.globalData.systemUserInfo.userId ? app.globalData.systemUserInfo.userId : '';
+			// if (!userId || userId == '' || userId==undefined) {
+			// 	that.showAuth=true
+			// 	appEv.authorizeUserInfo(res=>{
+			// 		if(res){
+			// 			that.shopInfo=app.globalData.shopInfo
+			// 			that.showAuth=false
+			// 		}
+			// 	})
+			// }
 		},
 		methods:{
 			// 商品详情信息
-			loadData:function(){
-				let that = this;
-				let type = this.type;
-				let data = {
-					specialArea:type
-				}
-				if(type == 3){
-					data.id = this.id
-				}else{
-					data.goodsId = this.goodsId
-				}
-				u_post("ShuZiTeaYW/shop/detailes",data).then(res => {
-                    if(res.status == 200){
-                        that.detail = res.goods
+			loadData(da){
+				post("goods/goodsDetail",da).then(res => {
+                    if(res.code === 0){
+                        this.detail = res.data.data
                     }else{
                         uni.showModal({
                             title: '提示',
@@ -218,6 +213,7 @@ import authorizeModule from '@/components/authorize-module/index'
                     }
                 })
 			},
+
 			//授权并登录
 			onAuthSuccess:function() {
 			    var that = this;
@@ -246,22 +242,29 @@ import authorizeModule from '@/components/authorize-module/index'
 			},
 			// 创建购买订单
 			toPayOrder:function(){
-				let that = this;
-				let url
-				if(this.type == 1){
-					url = '/pages/to-pay-list/index?count=' + this.buyNum + '&goodsId=' + this.goodsId + '&goodsType=1&ojsType=1'
-				}else if(this.type == 2){
-					url = '/pages/to-pay-list/index?count=' + this.buyNum + '&goodsType=2&goodsId=' + this.goodsId + '&ojsType=' + this.pfway + '&payType=2';
-				}else if(this.type == 3){
-					url = '/pages/to-pay-list/index?count=1&goodsType=4&ojsType=1&goodsPId=' + this.id
-				}else if(this.type == 4){
-					url = '/pages/to-pay-list/index?count=' + this.buyNum + '&goodsType=3&ojsType=1&goodsId=' + this.detail.goodsId
-				}else if(this.type == 7){
-					url = '/pages/to-pay-list/index?count=' + this.buyNum + '&goodsType=7&ojsType=1&goodsId=' + this.detail.goodsId
-				}
-				uni.navigateTo({
-					url:url
+				console.log(this.pfway);
+				this.goto("/pages/to-pay-list/index",{
+					...this.goodsDa,
+					is_sell: this.pfway,
+					num: this.buyNum,
 				})
+				
+				// let that = this;
+				// let url
+				// if(this.type == 1){
+				// 	url = '/pages/to-pay-list/index?count=' + this.buyNum + '&goodsId=' + this.goodsId + '&goodsType=1&ojsType=1'
+				// }else if(this.type == 2){
+				// 	url = '/pages/to-pay-list/index?count=' + this.buyNum + '&goodsType=2&goodsId=' + this.goodsId + '&ojsType=' + this.pfway + '&payType=2';
+				// }else if(this.type == 3){
+				// 	url = '/pages/to-pay-list/index?count=1&goodsType=4&ojsType=1&goodsPId=' + this.id
+				// }else if(this.type == 4){
+				// 	url = '/pages/to-pay-list/index?count=' + this.buyNum + '&goodsType=3&ojsType=1&goodsId=' + this.detail.goodsId
+				// }else if(this.type == 7){
+				// 	url = '/pages/to-pay-list/index?count=' + this.buyNum + '&goodsType=7&ojsType=1&goodsId=' + this.detail.goodsId
+				// }
+				// uni.navigateTo({
+				// 	url:url
+				// })
 			},
 			// 添加到购物车
 			SetCartGoodsList:function(){
@@ -313,31 +316,31 @@ import authorizeModule from '@/components/authorize-module/index'
 			},
 			// 点击立即购买或加入购物车
 			buttonClick:function(e){
+						// this.toPayOrder()
 				let that = this;
-                u_post("ShuZiTeaYW/userInfo/realName").then(res => {
-                    if(res.status == 200){
+                    // if(this.userinfo.is_authentication == 1){
                         that.btnIndex = e.index
                         that.$refs.shopping.open()
-                    }else{
-                        appEv.errTips('您还未实名')
-                        const infor = reqApi.identifyUserPayment()
-                        if(infor){
-                            infor.then(rea => {
-                                if(rea.status == 200){
-                                    uni.navigateTo({
-                                        url:'/pages/autonym-submit/index'
-                                    })
-                                }else if(rea.status == 999){
-                                    uni.navigateTo({
-                                        url:'/pages/autonym-pay/index'
-                                    })
-                                }else{
-                                    appEv.errTip(rea.msg)
-                                }
-                            })
-                        }
-                    }
-                })
+                    // }else{
+                        // appEv.errTips('您还未实名')
+
+                        // const infor = reqApi.identifyUserPayment()
+                        // if(infor){
+                        //     infor.then(rea => {
+                        //         if(rea.status == 200){
+                        //             uni.navigateTo({
+                        //                 url:'/pages/autonym-submit/index'
+                        //             })
+                        //         }else if(rea.status == 999){
+                        //             uni.navigateTo({
+                        //                 url:'/pages/autonym-pay/index'
+                        //             })
+                        //         }else{
+                        //             appEv.errTip(rea.msg)
+                        //         }
+                        //     })
+                        // }
+                    // }
 			},
 			// 点击关闭弹窗
 			closeBtn:function(){

+ 171 - 134
src/pages/to-pay-list/index.vue

@@ -14,7 +14,7 @@
 						<view class="set_text">修改</view>
 					</view>
 				</view>
-				<view class="add_name mar_t20">{{DefaultAddress.province}}{{DefaultAddress.city}}{{DefaultAddress.county}}{{DefaultAddress.address}}</view>
+				<view class="add_name mar_t20">{{DefaultAddress.address}}</view>
 			</block>
 			<block v-else>
 				<view class="add_address flex_c flex_ac flex_jc" @tap="chooseWXaddress">
@@ -27,14 +27,14 @@
 		
 		<!-- 商品信息 -->
 		<view class="goods_info mar_t20">
-			<view class="info_type">{{modularName}}</view>
-			<view class="goods flex_r" v-for="(item,index) in goodsInfo" :key="index">
-				<image class="goods_img" :src="item.goodsImgUrl" mode=""></image>
+			<view class="info_type">专区</view>
+			<view class="goods flex_r">
+				<image class="goods_img" :src="goodsInfo.goods.original_img" mode=""></image>
 				<view class="goods_con flex_c flex_jc flex_jb">
-					<view class="goods_name">{{item.goodsName}}</view>
+					<view class="goods_name">{{goodsInfo.goods.goods_name}}</view>
 					<view class="flex_r flex_ac flex_jb">
-						<view class="goods_msg">{{Data.goodsType == 5 ? item.goodsIntegral + '消费积分' : '¥' + item.goodsPrice}}</view>
-						<view class="goods_num">x {{item.buyCount ? item.buyCount : 1}}</view>
+						<view class="goods_msg">{{Data.type == 2 ? goodsInfo.trade_num + '消费积分' + '¥' + goodsInfo.trade_price : '¥' + goodsInfo.cost_price}}</view>
+						<view class="goods_num">x {{Data.num}}</view>
 					</view>
 				</view>
 			</view>
@@ -45,51 +45,51 @@
 		<view class="order mar_t20">
 			<view class="order_list flex_r flex_ac flex_jb">
 				<view class="list_name flex_r flex_jb"><text>数</text><text>量</text></view>
-				<view class="list_con">{{basicsInfo.buyCount}}</view>
+				<view class="list_con">{{Data.num}}</view>
 			</view>
-			<view class="order_list flex_r flex_ac flex_jb" v-if="Data.goodsType != 2 && Data.goodsType != 5 && Data.goodsType != 4 && Data.goodsType != 3 && Data.goodsType != 7">
+			<view class="order_list flex_r flex_ac flex_jb">
 				<view class="flex_r flex_ac">
 					<view class="list_name flex_r flex_jb"><text>运</text><text>费</text></view>
-					<view class="list_con p_color">({{basicsInfo.goodsFreightMsg}})</view>
+					<view class="list_con p_color">({{freight}}元/每套)</view>
 				</view>
-				<view class="list_con">¥{{basicsInfo.goodsFreight}}</view>
+				<view class="list_con">¥{{freight}}</view>
 			</view>
-			<view class="order_list flex_r flex_ac flex_jb" v-if="Data.goodsType == 2">
+			<view class="order_list flex_r flex_ac flex_jb" v-if="Data.type == 2">
 				<view class="flex_r flex_ac">
 					<view class="list_name flex_r flex_jb"><text>茶</text><text>宝</text></view>
-					<view class="list_con p_color">(可用{{basicsInfo.Integral}})</view>
+					<view class="list_con p_color">(可用{{userinfo.cha_bao}})</view>
 				</view>
 				<view class="list_con">{{basicsInfo.goodsTeaInt}}茶宝</view>
 			</view>
-			<view class="order_list flex_r flex_ac flex_jb" v-if="Data.goodsType == 2">
+			<view class="order_list flex_r flex_ac flex_jb" v-if="Data.type == 2">
 				<view class="flex_r flex_ac">
 					<view class="list_name flex_r flex_jb"><text>批</text><text>发</text><text>积</text><text>分</text></view>
-					<view class="list_con p_color">(可用{{basicsInfo.PfIntegral}})</view>
+					<view class="list_con p_color">(可用{{basicsInfo.integral}})</view>
 				</view>
 				<view class="list_con">{{basicsInfo.goodsPfInt}}批发积分</view>
 			</view>
-			<view class="order_list flex_r flex_ac flex_jb" v-if="Data.goodsType != 5">
+			<view class="order_list flex_r flex_ac flex_jb" v-if="Data.type != 5">
 				<view class="list_name flex_r flex_jb"><text>商</text><text>品</text><text>金</text><text>额</text></view>
 				<view class="list_con">¥{{basicsInfo.goodsTotalPrice}}</view>
 			</view>
-			<view class="order_list flex_r flex_ac flex_jb" v-if="Data.goodsType == 5">
+			<view class="order_list flex_r flex_ac flex_jb" v-if="Data.type == 5">
 				<view class="list_name flex_r flex_jb"><text>消</text><text>费</text><text>积</text><text>分</text></view>
 				<view class="list_con">{{basicsInfo.stayPay}}消费积分</view>
 			</view>
-			<view class="order_list flex_r flex_ac flex_jb" v-if="Data.goodsType == 5">
+			<view class="order_list flex_r flex_ac flex_jb" v-if="Data.type == 5">
 				<view class="list_name flex_r flex_jb"><text>可</text><text>用</text><text>积</text><text>分</text></view>
-				<view class="list_con">{{basicsInfo.userXfInt}}消费积分</view>
+				<view class="list_con">{{userinfo.integral}}消费积分</view>
 			</view>
-			<view class="order_list flex_r flex_ac flex_jb" v-if="(!Data.payType || Data.payType == 2 || Data.payType == 6) && Data.goodsType != 7">
+			<view class="order_list flex_r flex_ac flex_jb">
 				<view class="list_name flex_r flex_jb"><text>可</text><text>用</text><text>余</text><text>额</text></view>
-				<view class="list_con p_color">¥{{basicsInfo.userAccount}}</view>
+				<view class="list_con p_color">¥{{userinfo.user_money}}</view>
 			</view>
 		</view>
 		<!-- 订单信息-end -->
 		
 		<!-- 底部操作栏 -->
 		<view class="bar flex_r flex_ac flex_jb">
-			<view class="bar_info flex_r flex_ac">待支付<text>¥{{basicsInfo.zonPirce}}</text></view>
+			<view class="bar_info flex_r flex_ac">待支付<text>¥{{obligation}}</text></view>
 			<view class="pay_btn flex_r flex_ac flex_jc" @tap="payment">立即支付</view>
 		</view>
 		<!-- 底部操作栏-end -->
@@ -111,25 +111,55 @@ import { get, post, u_post } from "@/request/api.js";
 				goodsInfo:'', // 商品信息
 				modularName:'' ,// 商品类型
 				DefaultAddress: '' ,// 用户默认地址
-				basicsInfo:'' // 订单信息
+				basicsInfo:'', // 订单信息
+
+				freight: 0, //运费
+				userinfo: {},
+				obligation: 0, //待支付
 			};
 		},
-		onLoad:function(e){
+		onLoad(e){
 			this.Data = e
-			this.loadData()
-			this.loadAddress()
+			this.loadData(e)
+			// this.loadAddress()
+			this.userinfo = uni.getStorageSync('userinfo');
 		},
 		methods:{
-			loadData:function(){
-				let that = this;
-                u_post("ShuZiTeaYW/shop/confirmOrder",this.Data).then(res => {
-                    if(res.status == 200){
-                        that.goodsInfo = res.goodsInfo
-                        that.basicsInfo = res.basicsInfo
-                        that.modularName = res.modularName
-                    }
+			loadData(da){
+				post("goods/goodsDetail",da).then(res => {
+                    if(res.code === 0){
+                        this.goodsInfo = res.data.data
+						post("goods/freight",{type:da.type}).then(res => {
+							if(res.code === 0){
+								this.freight = res.data.freight;
+							}
+							// 计算待支付
+							let a = this.goodsInfo.cost_price * this.Data.num + parseFloat(this.freight);
+							let b = a - this.userinfo.user_money;
+							this.obligation = b > 0 ? b : 0
+						})
+					}
+                })
+				post("user/addressList").then(res => {
+                    if(res.code === 0){
+						let da = res.data.data;
+						for (const i of da) {
+							if(i.status == 1) {
+								this.DefaultAddress = i;
+								break;
+							}else this.DefaultAddress = da[0]
+						}
+					}
                 })
+                // u_post("ShuZiTeaYW/shop/confirmOrder",this.Data).then(res => {
+                //     if(res.status == 200){
+                //         that.goodsInfo = res.goodsInfo
+                //         that.basicsInfo = res.basicsInfo
+                //         that.modularName = res.modularName
+                //     }
+                // })
 			},
+
 			// 获取用户地址
 			loadAddress:function(){
 				let that = this;
@@ -139,109 +169,116 @@ import { get, post, u_post } from "@/request/api.js";
                     }
                 })
 			},
-			chooseWXaddress:function() {
-				var that = this;
-				uni.chooseAddress({
-					success: function (res) {
-						let default_address = {
-							city: res.cityName,
-							county: res.countyName,
-							address: res.detailInfo,
-							zipCode: res.postalCode,
-							province: res.provinceName,
-							mobile: res.telNumber,
-							name: res.userName
-						};
-						that.DefaultAddress = default_address;
-					},
-					fail: function (res) {
-						console.log(res);
-						if (res.errMsg == "chooseAddress:fail auth deny" || res.errMsg == "chooseAddress:fail:auth denied") {
-							that.flag = false;
-						}
-					}
-				})
+			chooseWXaddress() {
+				this.goto("/pages/xghc-addrress/userAddress");
+				// var that = this;
+				// uni.chooseAddress({
+				// 	success: function (res) {
+				// 		let default_address = {
+				// 			city: res.cityName,
+				// 			county: res.countyName,
+				// 			address: res.detailInfo,
+				// 			zipCode: res.postalCode,
+				// 			province: res.provinceName,
+				// 			mobile: res.telNumber,
+				// 			name: res.userName
+				// 		};
+				// 		that.DefaultAddress = default_address;
+				// 	},
+				// 	fail: function (res) {
+				// 		console.log(res);
+				// 		if (res.errMsg == "chooseAddress:fail auth deny" || res.errMsg == "chooseAddress:fail:auth denied") {
+				// 			that.flag = false;
+				// 		}
+				// 	}
+				// })
 			},
 			// 支付
 			payment:function(){
-				let that = this;
-				if(this.DefaultAddress == '' && this.Data.ojsType!=2){
-					appEv.errTips('请选择地址')
-					return false
-				}
-				let data = {
-					goodsType:this.Data.goodsType,
-					buyCount:this.Data.count,
-					payType:this.Data.payType ? this.Data.payType : 1,
-					ojsType:this.Data.ojsType ? this.Data.ojsType : ''
-				}
-				if(this.Data.goodsType == 6){
-					data.shoppingCartId=this.Data.goodsId
-				}else if(this.Data.goodsType == 4){
-					data.shoppingCartId=this.Data.goodsPId
-				}else{
-					data.goodsId=this.Data.goodsId
-				}
-				if(this.Data.ojsType!=2){
-					if(this.DefaultAddress.id && this.DefaultAddress.id != ''){
-						data.addressId=this.DefaultAddress.id
-					}else{
-						data = {
-							...data,
-							province : this.DefaultAddress.province,
-							city : this.DefaultAddress.city,
-							county : this.DefaultAddress.county,
-							address : this.DefaultAddress.address,
-							name : this.DefaultAddress.name,
-							mobile : this.DefaultAddress.mobile
-						}
-					}
-				}
-				uni.showModal({
-				    title: '提示',
-				    content: '是否确认支付',
-				    success: function (res) {
-				        if (res.confirm) {
-							let info = null
-							if(that.Data.goodsType == 6 || that.Data.goodsType == 4){
-								info = reqApi.ShoppingCartBuy(data)
-							}else{
-								info = reqApi.placeOrders(data)
-							}
-				            if(info){
-				            	info.then(res => {
-				            		if(res.data.status == 200){
-				            			if(res.data.payParam){
-				            				toPayOpre.toPay(res.data.payParam, (res) => {
-				            					if (!res) {
-				            						// 支付成功
-				            						uni.redirectTo({
-				            							url: '/pages/szw-order-list/index'
-				            						})
-				            					} else {
-				            						// 支付失败
-				            						uni.redirectTo({
-				            							url: '/pages/szw-order-list/index'
-				            						})
-				            					}
-				            				});
-				            			}else{
-				            				appEv.errTips('支付成功')
-											// 支付成功
-											uni.redirectTo({
-												url: '/pages/szw-order-list/index'
-											})
-				            			}
-				            		}else{
-				            			appEv.errTips(res.data.msg)
-				            		}
-				            	})
-				            }
-				        } else if (res.cancel) {
-				            console.log('用户点击取消');
-				        }
-				    }
-				});
+				post('goods/submitOrder',{
+					...this.Data,
+					address_id: this.DefaultAddress.id,
+				}).then(res => {
+
+				})
+				// let that = this;
+				// if(this.DefaultAddress == '' && this.Data.ojsType!=2){
+				// 	appEv.errTips('请选择地址')
+				// 	return false
+				// }
+				// let data = {
+				// 	goodsType:this.Data.goodsType,
+				// 	buyCount:this.Data.count,
+				// 	payType:this.Data.payType ? this.Data.payType : 1,
+				// 	ojsType:this.Data.ojsType ? this.Data.ojsType : ''
+				// }
+				// if(this.Data.goodsType == 6){
+				// 	data.shoppingCartId=this.Data.goodsId
+				// }else if(this.Data.goodsType == 4){
+				// 	data.shoppingCartId=this.Data.goodsPId
+				// }else{
+				// 	data.goodsId=this.Data.goodsId
+				// }
+				// if(this.Data.ojsType!=2){
+				// 	if(this.DefaultAddress.id && this.DefaultAddress.id != ''){
+				// 		data.addressId=this.DefaultAddress.id
+				// 	}else{
+				// 		data = {
+				// 			...data,
+				// 			province : this.DefaultAddress.province,
+				// 			city : this.DefaultAddress.city,
+				// 			county : this.DefaultAddress.county,
+				// 			address : this.DefaultAddress.address,
+				// 			name : this.DefaultAddress.name,
+				// 			mobile : this.DefaultAddress.mobile
+				// 		}
+				// 	}
+				// }
+				// uni.showModal({
+				//     title: '提示',
+				//     content: '是否确认支付',
+				//     success: function (res) {
+				//         if (res.confirm) {
+				// 			let info = null
+				// 			if(that.Data.goodsType == 6 || that.Data.goodsType == 4){
+				// 				info = reqApi.ShoppingCartBuy(data)
+				// 			}else{
+				// 				info = reqApi.placeOrders(data)
+				// 			}
+				//             if(info){
+				//             	info.then(res => {
+				//             		if(res.data.status == 200){
+				//             			if(res.data.payParam){
+				//             				toPayOpre.toPay(res.data.payParam, (res) => {
+				//             					if (!res) {
+				//             						// 支付成功
+				//             						uni.redirectTo({
+				//             							url: '/pages/szw-order-list/index'
+				//             						})
+				//             					} else {
+				//             						// 支付失败
+				//             						uni.redirectTo({
+				//             							url: '/pages/szw-order-list/index'
+				//             						})
+				//             					}
+				//             				});
+				//             			}else{
+				//             				appEv.errTips('支付成功')
+				// 							// 支付成功
+				// 							uni.redirectTo({
+				// 								url: '/pages/szw-order-list/index'
+				// 							})
+				//             			}
+				//             		}else{
+				//             			appEv.errTips(res.data.msg)
+				//             		}
+				//             	})
+				//             }
+				//         } else if (res.cancel) {
+				//             console.log('用户点击取消');
+				//         }
+				//     }
+				// });
 				
 			}
 		}

+ 238 - 0
src/pages/xghc-addrress/userAddress.vue

@@ -0,0 +1,238 @@
+<template>
+	<view class="container">
+		<form @submit="formSubmit">
+			<view class='addAddress'>
+				<view class="pad30">
+					<view class='default acea-row row-middle borderRadius15'>
+						<uni-easyinput type="textarea" v-model="addressValue" placeholder="粘贴地址信息,自动拆分姓名、电话和地址" @blur="identify()" />
+						<!-- <input v-model="addressValue" type="text" placeholder="粘贴地址信息,自动拆分姓名、电话和地址" 
+						placeholder-class='placeholder' style="width:100%;" 
+						@blur="identify()"> -->
+					</view>
+				</view>
+				<view class="pad30 mt-22">
+					<view class='list borderRadius15'>
+						<view class='item acea-row row-between-wrapper'>
+							<view class='name'>姓名</view>
+							<input type='text' placeholder='请输入姓名' name='real_name' v-model="userAddress.real_name"
+								placeholder-class='placeholder' />
+						</view>
+						<view class='item acea-row row-between-wrapper'>
+							<view class='name'>联系电话</view>
+							<input type='number' placeholder='请输入联系电话' name="phone" v-model='userAddress.phone'
+								placeholder-class='placeholder' pattern="\d*" />
+						</view>
+						<view class='item acea-row row-between-wrapper'>
+							<view class='name'>所在地区</view>
+							<view class="address acea-row row-between">
+								<input type='text' placeholder='请填写具体地址' name='region' placeholder-class='placeholder'
+									v-model='userAddress.region' class="detail" />
+							</view>
+						</view>
+						<view class='item acea-row row-between-wrapper'>
+							<view class='name'>详细地址</view>
+							<view class="address">
+								<input type='text' placeholder='请填写具体地址' name='detail' placeholder-class='placeholder'
+									v-model='userAddress.detail' class="detail" />
+							</view>
+						</view>
+						<view class='item acea-row row-between-wrapper'>
+							<view class='name'>详细地址</view>
+							<view class="address">
+								<uni-data-checkbox v-model="is_default" :localdata="range"></uni-data-checkbox>
+							</view>
+						</view>
+					</view>
+				</view>
+				<button class='keepBnt bg-color' form-type="submit">立即保存</button>
+			</view>
+		</form>
+	</view>
+</template>
+<script>
+import { get, post, u_post } from "@/request/api.js";
+	import AddressParse from './zh-address-parse.min.js'
+let app = getApp();
+var appEv = app.$vm.$options;
+	export default {
+		data() {
+			return {
+				userAddress: {
+					real_name:"",
+					phone:"",
+					region:"",
+					detail:"",
+				}, //地址详情
+				addressValue:"",
+				is_default: 0, //是否设为默认地址
+				range: [{"value": 0,"text": "否"	},{"value": 1,"text": "是"}]
+			}
+		},
+		components:{
+			
+		},
+		onLoad(){
+			
+		},
+		methods: {
+			identify(){
+				const options = {
+				  type: 0, // 哪种方式解析,0:正则,1:树查找
+				  textFilter: [], // 预清洗的字段
+				  nameMaxLength: 4, // 查找最大的中文名字长度
+				}
+				// type参数0表示使用正则解析,1表示采用树查找, textFilter地址预清洗过滤字段。
+				if(!!this.addressValue){
+					const parseResult = AddressParse(this.addressValue, options)
+					// console.log(parseResult);
+					this.userAddress.real_name = parseResult.name;
+					this.userAddress.phone = parseResult.phone;
+					this.userAddress.detail = parseResult.detail;
+					this.userAddress.region = parseResult.province + '/' + parseResult.city + '/' + parseResult.area;
+				}
+			},
+			formSubmit(){
+				post("user/addAddress",{
+					address: this.userAddress.region + this.userAddress.detail,
+					mobile: this.userAddress.phone,
+					name: this.userAddress.real_name,
+					is_default: this.is_default
+				}).then(res => {
+                	if (res.code === 0) {
+						appEv.errTips(res.msg);
+						setTimeout(() => {
+							uni.navigateBack();
+						}, 1500);
+					}
+				})
+				// this.$emit('addressConfirm',this.userAddress)
+			}
+		},
+	}
+</script>
+<style lang="scss" scoped>
+	.container{
+		background-color: #f5f5f5;
+		height: 100vh;
+		padding-top:30rpx;
+	}
+	
+	.pad30 {
+		padding: 0 30rpx
+	}
+	
+	.p_center {
+		text-align: center;
+	}
+	
+	.acea-row {
+		display: flex;
+	}
+	.row-middle {
+		align-items: center
+	}
+	.row-between-wrapper {
+		align-items: center;
+		justify-content: space-between
+	}
+	.borderRadius15 {
+		border-radius: 15rpx !important;
+	}
+	.fontcolor{
+		color: var(--view-theme);
+	}
+	.addAddress .list {
+		background-color: #fff;
+	}
+	
+	.addAddress .list .item {
+		padding: 30rpx;
+		border-top: 1rpx solid #eee;
+		position: relative;
+	}
+	
+	.addAddress .list .item .detail{
+		width: 368rpx;
+	}
+	
+	.addAddress .list .item .location{
+		position: absolute;
+		right: 46rpx;
+		top: 50%;
+		margin-top: -40rpx!important;
+		font-size: 24rpx;
+		text-align: center;
+	}
+	
+	.addAddress .list .item .icon-dizhi{
+		 font-size: 36rpx!important;
+	}
+	
+	.addAddress .list .item .name {
+		width: 195rpx;
+		font-size: 30rpx;
+		color: #333;
+	}
+	
+	.addAddress .list .item .address {
+		flex: 1;
+	}
+	
+	.addAddress .list .item .address .addressCon{
+		width: 360rpx;
+	}
+	
+	.addAddress .list .item .address .addressCon .tip{
+		font-size: 21rpx;
+		margin-top: 4rpx;
+	}
+	
+	.addAddress .list .item input {
+		/* // width: 475rpx; */
+		flex: 1;
+		font-size: 30rpx;
+	}
+	
+	.placeholder {
+		color: #ccc;
+	}
+	
+	.addAddress .list .item .picker {
+		width: 430rpx;
+		font-size: 30rpx;
+	}
+	
+	.addAddress .list .item .iconfont {
+		font-size: 30rpx;
+		margin-top: 4rpx;
+	}
+	
+	.addAddress .default {
+		padding: 30rpx;
+		/* height: 90rpx; */
+		background-color: #fff;
+	}
+	
+	.addAddress .default checkbox {
+		margin-right: 15rpx;
+	}
+	
+	.addAddress .keepBnt {
+		width: 690rpx;
+		height: 86rpx;
+		border-radius: 50rpx;
+		text-align: center;
+		line-height: 86rpx;
+		margin: 50rpx auto;
+		font-size: 32rpx;
+		color: #fff;
+	}
+	
+	
+	.mt-22{
+		margin-top: 22rpx;
+	}
+	.bg-color {
+		background-color: #dd524d;
+	}
+</style>

文件差異過大導致無法顯示
+ 0 - 0
src/pages/xghc-addrress/zh-address-parse.min.js


部分文件因文件數量過多而無法顯示