ソースを参照

对接胎号查询接口

caojunjie 4 年 前
コミット
75064daea7
1 ファイル変更107 行追加18 行削除
  1. 107 18
      pages/me/scancodequery/result.vue

+ 107 - 18
pages/me/scancodequery/result.vue

@@ -1,49 +1,136 @@
 <!-- 胎号查询成功页面 -->
 <template>
 	<view>
-		<view class="head">
+		<view class="head" v-if="empty == true">
+			<view class="tips">
+				<image src="../../../static/sailun/successful.png" mode=""></image>
+				<view>查询失败</view>
+			</view>
+			<view class="stripe"></view>
+			<view class="roll">
+				<view>查询失败</view>
+				<view>
+					<view></view>
+					<view></view>
+					<u-line color="#f4f4f4" border-style="dashed" :hair-line="true" length="94%" style="margin: 0 auto;padding-top: 30rpx;" />
+				</view>
+				<view class="Exhibition">
+					<u-empty text="查询失败" mode="list"></u-empty>
+				</view>
+			</view>
+			<u-button type="primary" shape="circle" class="button" @click="scanning">立即查询</u-button>
+		</view>
+		
+		<view class="head" v-else>
 			<view class="tips">
 				<image src="../../../static/sailun/successful.png" mode=""></image>
 				<view>查询成功</view>
 			</view>
 			<view class="stripe"></view>
 			<view class="roll">
-				<view>232654561651</view>
+				<view>{{tireNumber}}</view>
 				<view>
 					<view></view>
 					<view></view>
 					<u-line color="#f4f4f4" border-style="dashed" :hair-line="true" length="94%" style="margin: 0 auto;padding-top: 30rpx;" />
 				</view>
 				<view class="Exhibition">
-					<view><text>轮胎胎号</text><text>232654561651</text></view>
-					<view><text>轮胎类型</text><text>扫码出库</text></view>
-					<view><text>轮胎品牌</text><text>赛轮轮胎</text></view>
-					<view><text>轮胎规格</text><text>12R22.5</text></view>
-					<view><text>创建时间</text><text>2020-02-22 10:22:23</text></view>
+					<view><text>轮胎胎号</text><text>{{tireNumber}}</text></view>
+					<view><text>轮胎类型</text><text>{{mouldType}}</text></view>
+					<view><text>轮胎品牌</text><text>{{brand}}</text></view>
+					<view><text>轮胎规格</text><text>{{specification}}</text></view>
+					<view><text>创建时间</text><text>{{createTime}}</text></view>
 				</view>
 			</view>
-			<u-button type="primary" shape="circle" class="button">继续查询</u-button>
+			<u-button type="primary" shape="circle" class="button" @click="scanning">继续查询</u-button>
 		</view>
 	</view>
 </template>
 
 <script>
+	import {
+		request
+	} from '../../../common/request/request'
+	require("promise.prototype.finally").shim()
 	export default {
 		data() {
 			return {
-				
-			};
+				datalist: '',
+				empty: true,
+				tireNumber: "未查询",
+				mouldType: '未查询',
+				brand: '未查询',
+				specification: '未查询',
+				createTime: '未查询'
+			}
 		},
-		created() {
-			this.add()
+		onReady() {
+			uni.getNetworkType({
+				success: function(res) {
+					let none = res.networkType
+					console.log(res.networkType);
+					if (none == 'none') {
+						uni.showToast({
+							icon: 'none',
+							title: '无网络,请连接网络后再试~',
+							position: "bottom"
+						})
+					}
+				}
+			});
+			setTimeout(() => {
+				this.scanning()
+			}, 100)
+
 		},
 		methods: {
-			add(){
+			rendering() {
+				console.log(this.datalist)
+				request({
+					url: '/myapp/mouldSelect',
+					method: 'Post',
+					data: {
+						storeId: this.$store.state.storeInfo.storeId,
+						userId: this.$store.state.storeInfo.userId,
+						tireNumber: this.datalist,
+					}
+				}).then(res => {
+					console.log(res.data)
+					if(res.data.code == 0){
+						this.empty = false
+						this.tireNumber = res.data.data.tireNumber
+						this.mouldType = res.data.data.mouldType
+						this.brand = res.data.data.brand
+						this.specification = res.data.data.specification
+						this.createTime = res.data.data.createTime
+					}else if (res.data.code == 500) {
+						this.empty = true
+						uni.showToast({
+							icon: 'none',
+							title: res.data.msg,
+							position: "bottom"
+						})
+					}
+				}).catch(err => {
+					console.log(err)
+					uni.showToast({
+						icon: 'none',
+						title: '出错了请联系管理员~',
+						position: "bottom"
+					})
+				}).finally(() => {
+					// Loading.close()
+				})
+			},
+			scanning() {
+				let this_ = this
 				uni.scanCode({
-				    success: function (res) {
-				        console.log('条码类型:' + res.scanType);
-				        console.log('条码内容:' + res.result);
-				    }
+					success: function(res) {
+						console.log('条码类型:' + res.scanType);
+						console.log('条码内容:' + res.result);
+						this_.datalist = res.result
+						this_.rendering()
+					}
 				})
 			}
 		}
@@ -138,9 +225,11 @@
 		margin: 0 auto;
 		margin-top: 25rpx;
 	}
-	.Exhibition>view{
+
+	.Exhibition>view {
 		margin-bottom: 10rpx;
 	}
+
 	.Exhibition>view>text:nth-child(2) {
 		float: right;
 	}