Browse Source

扫码入库接口对接完成

caojunjie 4 years ago
parent
commit
5132153ea7
6 changed files with 281 additions and 165 deletions
  1. 1 0
      README.md
  2. 1 1
      main.js
  3. 25 16
      manifest.json
  4. 109 79
      pages/home/Scan-code-in/index.vue
  5. 31 31
      pages/home/index.vue
  6. 114 38
      pages/home/scancode/index.vue

+ 1 - 0
README.md

@@ -8,6 +8,7 @@
 ## 需安装配置
 axios参考[axios](http://www.axios-js.com/zh-cn/)官网地址
 finally参考[安装命令](npm i promise.prototype.finally -S)官网地址无
+vue-baidu-map参考[安装命令](npm install vue-baidu-map --save)
 
 
 ## 说明

+ 1 - 1
main.js

@@ -65,4 +65,4 @@ app.$mount()
 
 //扫码组件
 import scan from '@/common/p-scan/scan.vue'
-Vue.component('scan',scan)
+Vue.component('scan', scan)

+ 25 - 16
manifest.json

@@ -24,38 +24,47 @@
         "usingComponents" : true,
         "nvueCompiler" : "uni-app",
         "compilerVersion" : 3,
-        "modules" : {},
+        "modules" : {
+            "Maps" : {}
+        },
         "distribute" : {
             "android" : {
                 "permissions" : [
-                    "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
-                    "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
-                    "<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>",
-                    "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
-                    "<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
-                    "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
+                    "<uses-feature android:name=\"android.hardware.camera\"/>",
                     "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
-                    "<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>",
+                    "<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
+                    "<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
                     "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
+                    "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
+                    "<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
                     "<uses-permission android:name=\"android.permission.CAMERA\"/>",
-                    "<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
+                    "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
+                    "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
+                    "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
                     "<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
                     "<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
+                    "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
+                    "<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>",
+                    "<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
                     "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
-                    "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
+                    "<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
+                    "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
                     "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
-                    "<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
-                    "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
-                    "<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
-                    "<uses-feature android:name=\"android.hardware.camera\"/>",
-                    "<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
+                    "<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>",
                     "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
                 ],
                 "abiFilters" : [ "armeabi-v7a", "arm64-v8a" ]
             },
             "ios" : {},
             "sdkConfigs" : {
-                "ad" : {}
+                "ad" : {},
+                "maps" : {
+                    "baidu" : {
+                        "appkey_ios" : "",
+                        "appkey_android" : "4wYVsEvjrdDXtsbRYsNTy1f01PAYbZin"
+                    }
+                },
+                "oauth" : {}
             },
             "icons" : {
                 "android" : {

+ 109 - 79
pages/home/Scan-code-in/index.vue

@@ -1,116 +1,144 @@
 <template>
-	<!-- 扫码库确认页面 -->
-	<view class="">
+	<!-- 扫码库确认页面 -->
+	<view>
 		<view class="header">
-		</view>
-		<view class="content">
-			<view class="content-one">
-				<view>胎号</view>
-				<view>物料</view>
-				<view>预计奖励</view>
-			</view>
-			<view v-for="(item,index) in datalist" :key="index">
-				<view class="content-two">
-					<view>{{item.title}}</view>
-					<view>{{item.type}}</view>
-					<view>{{item.money}}元</view>
+			<view class="behind"></view>
+			<view class="content">
+				<view class="content-one">
+					<view>胎号</view>
+					<view>物料</view>
+					<view>预计奖励</view>
+				</view>
+				<view v-for="(item,index) in dalist" :key="index">
+					<view class="content-two">
+						<view>{{item.tireNumber}}</view>
+						<view>{{item.maktx}}</view>
+						<view>{{item.rewardMoney}}元</view>
+					</view>
 				</view>
-			</view>
 			
-			<view class="content-three">
-				<view>
-					 合计:21元
+				<view class="content-three">
+					<view>
+						合计:{{total}}元
+					</view>
 				</view>
 			</view>
 			<view class="content-four">
 				注:请完善请完善请完善请完善请完善请完善请完善
 			</view>
 		</view>
-		
-		<view class="tail">
+		<u-toast ref="repeat" position="bottom" />
+		<view class="tail" @click="Submit">
 			扫码确认
 		</view>
 	</view>
 </template>
 
 <script>
+	import {
+		request
+	} from '../../../common/request/request'
+	require("promise.prototype.finally").shim()
 	export default {
 		data() {
 			return {
-				datalist: [
-					{
-						title: '202134103765',
-						type: '165/60r1475hb h15bgbl',
-						money: '3'
-					},
-					{
-						title: '202134103765',
-						type: '165/60r1475hb h15bgbl',
-						money: '3'
-					},
-					{
-						title: '202134103765',
-						type: '165/60r1475hb h15bgbl',
-						money: '3'
-					},
-					{
-						title: '202134103765',
-						type: '165/60r1475hb h15bgbl',
-						money: '3'
-					},
-					{
-						title: '202134103765',
-						type: '165/60r1475hb h15bgbl',
-						money: '3'
-					},
-					{
-						title: '202134103765',
-						type: '165/60r1475hb h15bgbl',
-						money: '3'
-					},
-					
-				]
+				dalist: [],
+				total: 0
 			}
 		},
-	
-		onLoad() {
-	
+		created() {
+			this.getDatalist()
 		},
-	
 		methods: {
-	
-		},
-	}
+			getDatalist() {
+				uni.$on('update', data => {
+							this.datalist = data.materialList
+							request({
+								url: '/storeScan/getTyreReword',
+								method: 'Post',
+								data: {
+									storeId: '1000',
+									userId: '123',
+									materialList: this.datalist
+								}
+							}).then(res => {
+									this.dalist = res.data.data
+									
+									for (let i = 0; i < this.dalist.length; i++) {
+										this.total += parseInt(this.dalist[i].rewardMoney)
+									}
+									return this.total
+										
+									}).catch(err => {
+									console.log(err)
+								}).finally(() => {
+									Loading.close()
+								})
+							})
+					},
+					Submit() {
+						request({
+							url: '/storeScan/storeScanTyres',
+							method: 'Post',
+							data: {
+								storeId: '1000',
+								userId: '123',
+								scanAddress: '中国',
+								longitude: '1213.61256',
+								latitude: '541651.56',
+								materialList: this.datalist
+							}
+						}).then(res => {
+							console.log(res.data.msg)
+							this.$refs.repeat.show({
+								title: res.data.msg,
+								type: 'default',
+								position: 'bottom'
+							})
+						}).catch(err => {
+							console.log(err.data.msg)
+						}).finally(() => {
+							Loading.close()
+						})
+					}
+			},
+		}
 </script>
 
 <style lang="scss" scoped>
-	.header {
+	.behind{
 		width: 100%;
-		height: 280rpx;
+		height: 230rpx;
+		margin-bottom: -200rpx;
 		background-color: #0094FE;
 	}
+	.header {
+		width: 100%;
+	}
 
 	.content {
 		width: 711rpx;
 		// height: 852rpx;
-		position: absolute;
-		top: 40rpx;
-		left: 20rpx;
 		background: #FFFFFF;
-		box-shadow: 0px 0px 24px 0px rgba(101, 176, 249, 0.41);
-		border-radius: 20px;
+		box-shadow: 0rpx 0rpx 24rpx 0rpx rgba(101, 176, 249, 0.41);
+		border-radius: 20rpx;
+		padding-top: 10rpx;
+		padding-bottom: 10rpx;
+		margin: 0 auto;
 	}
 
 	.content-one {
 		display: flex;
 		justify-content: space-between;
 	}
+
 	.content-one:nth-child(1) {
 		margin-left: 90rpx;
 		margin-right: 50rpx;
 		font-weight: bold;
 		margin-top: 30rpx;
 	}
+
 	.content-two {
 		display: flex;
 		justify-content: space-between;
@@ -122,33 +150,36 @@
 		font-size: 28rpx;
 		border-bottom: 1rpx solid #E8E8E8;
 	}
+
 	.content-two>view:nth-child(2) {
-	     width: 240rpx;
-		 line-height: 53rpx;
-		 text-align: center;
-		 margin-right: 100rpx;
+		width: 240rpx;
+		line-height: 53rpx;
+		text-align: center;
+		margin-right: 100rpx;
 	}
+
 	.content-two>view:nth-child(3) {
-	     color: #149EE2;
-		 margin-right: 50rpx;
+		color: #149EE2;
+		margin-right: 50rpx;
 	}
+
 	.tail {
 		width: 678rpx;
 		line-height: 83rpx;
 		background: #0095FF;
-		border-radius: 10rpx;
-		position: fixed;
-		top: 1100rpx;
-		left: 36rpx;
 		color: #fff;
 		text-align: center;
+		margin: 0 auto;
+		margin-top: 60rpx;
+		border-radius: 15rpx;
 	}
-		
+
 	.content-three>view:nth-child(1) {
 		margin-left: 500rpx;
 		line-height: 80rpx;
 		font-weight: bolder;
 	}
+
 	.content-four {
 		color: #acacac;
 		font-size: 24rpx;
@@ -156,5 +187,4 @@
 		margin-left: 20rpx;
 		margin-bottom: 50rpx;
 	}
-	
 </style>

+ 31 - 31
pages/home/index.vue

@@ -67,24 +67,24 @@
 					title: '加载中...'
 				});
 				request({
-					url: '/homepage/getBanners',
-					method: 'post',
-				data: {
-					"storeId": '1000',
-					"showPosition": 0, //门店0
-					}
-				}).then(res => {
-					this.list = res.data.data
-					this.bannersList = this.list.map(t => t.imgPath)
-				}).catch(err => {
-					console.log(err)
-				})
-				.finally(() => {
-					setTimeout(() => {
-						uni.hideLoading();
-						this.loading = false;
-					}, 1000)
-				})
+						url: '/homepage/getBanners',
+						method: 'post',
+						data: {
+							"storeId": '1000',
+							"showPosition": 0, //门店0
+						}
+					}).then(res => {
+						this.list = res.data.data
+						this.bannersList = this.list.map(t => t.imgPath)
+					}).catch(err => {
+						console.log(err)
+					})
+					.finally(() => {
+						setTimeout(() => {
+							uni.hideLoading();
+							this.loading = false;
+						}, 1000)
+					})
 			},
 			//消息文字跑马灯
 			getTiceList() {
@@ -98,18 +98,18 @@
 							"storeId": "1000",
 							"contentType": "1" //门店1
 						}
-				}).then(res => {
-					this.list = res.data.data
-					this.noticebarList = this.list.map(t => t.msgContent)
-				}).catch(err => {
-					console.log(err)
-				})
-				.finally(() => {
-					setTimeout(() => {
-						uni.hideLoading();
-						this.loading = false;
-					}, 1000)
-				})
+					}).then(res => {
+						this.list = res.data.data
+						this.noticebarList = this.list.map(t => t.msgContent)
+					}).catch(err => {
+						console.log(err)
+					})
+					.finally(() => {
+						setTimeout(() => {
+							uni.hideLoading();
+							this.loading = false;
+						}, 1000)
+					})
 			},
 			scancodeIn() {
 				this.$u.route({
@@ -118,7 +118,7 @@
 			},
 			scancodeOut() {
 				this.$u.route({
-					url: 'pages/home/scancode/index',
+					url: 'pages/home/scancode/new_file',
 				})
 			},
 			inStock() {

+ 114 - 38
pages/home/scancode/index.vue

@@ -1,16 +1,20 @@
 <template>
-
 	<view class="content">
 		<view class="text-area">
-				<scan @getCode="getScanCode"/>
+			<scan @getCode="getScanCode" />
 		</view>
 		<view class="stripe"></view>
 		<view class="roll">
 			<view>
-				<view @click="show = true">
+				<view @click="show =! show">
 					<u-icon name="edit-pen"></u-icon>手动录入
 				</view>
-				<view>{{tips}}:{{number}}</view>
+				<view class="" v-if="show==true">
+					<input type="text" value="wocao" style="background-color: #DD6161;width: 60%;font-size: 42rpx;border: 1rpx solid #000;" />
+				</view>
+				<view class="" v-else>
+					<view>{{tips}}:{{number}}</view>
+				</view>
 			</view>
 			<view>
 				<view></view>
@@ -24,68 +28,139 @@
 					<u-tr class="u-tr">
 						<u-th class="u-th" width="30%">胎号</u-th>
 						<u-th class="u-th">规格</u-th>
-						<u-th class="u-th" width="15%"></u-th>
+						<u-th class="u-th" width="15%">操作</u-th>
 					</u-tr>
 					<u-tr class="u-tr" :key="index" v-for="(item, index) in lisi">
-						<u-td class="u-td" width="30%">{{item.name}}</u-td>
-						<u-td class="u-td">{{item.Specifications}}</u-td>
-						<u-td class="u-td" width="15%">删除</u-td>
+						<u-td class="u-td" width="30%">{{item.tireNumber}}</u-td>
+						<u-td class="u-td">{{item.maktx}}</u-td>
+						<u-td class="u-td" width="15%"><text @click="confirm(index)" style="color: #FA3534;">删除</text></u-td>
 					</u-tr>
 				</u-table>
 				<u-divider color="rgb(144, 147, 153)" half-width="200" border-color="rgb(144, 147, 153)" margin-top="40">没有更多了</u-divider>
 			</view>
 		</view>
 		<view class="determine">
-			<u-button type="primary" :ripple="true" shape="circle" @click="scancodein">扫码确认</u-button>
+			<u-button type="primary" shape="circle" @click="scancodein">扫码确认</u-button>
 		</view>
 		<view>
 		</view>
+		<u-toast ref="repeat" position="bottom" />
+		
+		
 	</view>
 </template>
 
 <script>
+	import {
+		request
+	} from '../../../common/request/request'
+	require("promise.prototype.finally").shim()
 	export default {
 		data() {
 			return {
 				tips: '提示',
 				number: '请扫码入库',
 				nbTitle: '扫码标题',
-				i: 1,
-				lisi: [{
-					name: '123456789154Sad',
-					Specifications: '175/70R14 88T XL BH15 BGBL'
-				}],
+				content: '东临碣石,以观沧海',
+				number_s: '',
+				lisi: [],
 				background: {
 					backgroundColor: '#0094fe',
-				}
-			}
-		},
-		onLoad() {
+				},
+				show: true,
+				zoom:18,//地图相关设置
+				center:{lng:0,lat:0}
 
-		},
-		onReady() {
 
+			}
+		},
+		created() {
+			
 		},
 		methods: {
-			bug() {
-				console.log("成功")
-				this.i++
-				this.lisi.push({
-					name: this.i,
-					Specifications: this.i
-				})
-			},
 			//获取扫码控件
 			getScanCode(val) {
 				console.log(val)
 				this.number = val
-				this.tips = "胎号"
-				this.bug()
+				this.number_s = val
+				request({
+						url: '/storeScan/storeScanGetTyre',
+						method: 'Post',
+						data: {
+							storeId: '1000',
+							userId: '123',
+							tyreNum: this.number_s
+						}
+					}).then(res => {
+						this.tips = "胎号"
+						for (let i = 0; i < this.lisi.length; i++) {
+							if (this.lisi[i].tireNumber == res.data.data[0].tirenumber) {
+								this.$refs.repeat.show({
+									title: '请勿重复扫码',
+									type: 'default',
+									position: 'bottom'
+								})
+								return
+							} else if (res.data.data[0].flagRegular == 1) {
+								this.$refs.repeat.show({
+									title: '轮胎非正规',
+									type: 'default',
+									position: 'bottom'
+								})
+								return
+							}
+						}
+						this.$refs.repeat.show({
+							title: '扫码成功',
+							type: 'success',
+							position: 'bottom'
+						})
+						console.log("我成功啦")
+						this.lisi.push({
+							specs: res.data.data[0].specs,
+							flagRegular: res.data.data[0].isRegular,
+							diameter: res.data.data[0].diameter,
+							maktx: res.data.data[0].maktx,
+							pattern: res.data.data[0].pattern,
+							soldToPartyKunnr: res.data.data[0].soldToPartyKunnr,
+							matnr: res.data.data[0].matnr,
+							tireNumber: res.data.data[0].tirenumber,
+							brand: res.data.data[0].brand,
+							shippedDate: res.data.data[0].shippedDate,
+							scanWay: '1'
+						})
+						console.log(this.lisi)
+					}).catch(err => {
+						this.$refs.repeat.show({
+							title: "请重新扫码",
+							type: 'default',
+							position: 'bottom'
+						})
+						console.log(err)
+					})
+					.finally(() => {
+						// Loading.close()
+					})
+			},
+			confirm(index) {
+				console.log(index + "什么情况")
+				this.lisi.splice(index, 1)
 			},
 			scancodein() {
-				this.$u.route({
-					url: 'pages/home/Scan-code-in/index'
-				})
+				if (this.lisi == '') {
+					this.$refs.repeat.show({
+						title: '请扫码后再点击!',
+						type: 'default',
+						position: 'bottom'
+					})
+				} else { //解
+					this.$u.route({
+						url: 'pages/home/Scan-code-in/index'
+					})
+					uni.$emit('update', {
+						materialList: this.lisi
+					})
+				}
 			}
 		}
 	}
@@ -94,16 +169,17 @@
 <style lang="scss" scoped>
 	.generate {
 		width: 98%;
-		height: 420rpx;
-		overflow:auto;
+		height: 300rpx;
+		overflow: auto;
 		margin: 0 auto;
 		margin-top: 120rpx;
 	}
 
 	.determine {
 		width: 690rpx;
-		margin-top: 330rpx;
+		margin-top: 30rpx;
 	}
+
 	.content {
 		display: flex;
 		flex-direction: column;
@@ -122,7 +198,7 @@
 	}
 
 	.stripe {
-		width: 720rpx;
+		width: 740rpx;
 		height: 30rpx;
 		background-color: #00A0EA;
 		border-radius: 12rpx;
@@ -149,7 +225,7 @@
 	}
 
 	.roll {
-		width: 690rpx;
+		width: 710rpx;
 		height: auto;
 		background: #FFFFFF;
 		margin: 0 auto;