From 6087ba7d24f2353c2d01a5e5a384d5a20f97a19b Mon Sep 17 00:00:00 2001 From: qingyiay <2386314947@qq.com> Date: 星期一, 15 五月 2023 08:10:53 +0800 Subject: [PATCH] 增加路线规划,样式修改 --- pages/public-page/forward/forward.vue | 296 +++++- pages.json | 34 pages/public-page/faYunstatisticsDetails/faYunstatisticsDetails.vue | 120 +- pages/customer-page/customer-index/fayunPlanDetails/fayunPlanDetails.vue | 14 pages/tabbar-page/index-tabbar/index-tabbar.vue | 32 pages/driver-page/driver-index/bill-of-lading-details/coal-pick-up-bill/coal-pick-up-bill.vue | 16 App.vue | 35 pages/driver-page/driver-index/driver-index.vue | 163 ++- store/index.js | 5 pages/driver-page/driver-index/bill-of-lading-details/weighingDevice/weighingDevice.vue | 66 + /dev/null | 31 pages/public-page/mapRoute/mapRoute.vue | 223 +++++ utils/qqmap-wx-jssdk.js | 1122 ++++++++++++++++++++++++++++ manifest.json | 2 static/image/banner/location.png | 0 static/image/banner/notice.png | 0 pages/public-page/message/message.vue | 21 pages/customer-page/customer-my/faYunstatistics/faYunstatistics.vue | 115 ++ pages/driver-page/driver-index/bill-of-lading-details/bill-of-lading-details.vue | 10 pages/customer-page/customer-index/fayunPlanDetails/fayunPlanMore/fayunPlanMore.vue | 85 + 20 files changed, 2,013 insertions(+), 377 deletions(-) diff --git a/App.vue b/App.vue index 681a4b3..697e173 100644 --- a/App.vue +++ b/App.vue @@ -1,19 +1,22 @@ <script> +import { mapState, mapMutations } from 'vuex'; export default { onShow() {}, - methods: {} - // created() { - // uni.loadFontFace({ - // family: 'siYuanLight', // 瀛椾綋鍚嶇О锛屽彲浠ヨ嚜瀹氫箟 - // source: 'url("/utils/fonts/siyuan.OTF")', // 瀛椾綋鏂囦欢璺緞 - // success() { - // console.log('瀛椾綋鍔犺浇鎴愬姛'); - // }, - // fail() { - // console.log('瀛椾綋鍔犺浇澶辫触'); - // } - // }); - // } + onHide() { + console.log('appvue闅愯棌鍚庡彴'); + this.changeisconnect(false); + if (!this.globalisconnect) { + uni.switchTab({ + url: '/pages/tabbar-page/index-tabbar/index-tabbar' + }); + } + }, + methods: { + ...mapMutations(['changeisconnect']) + }, + computed: { + ...mapState(['globalisconnect']) + } }; </script> @@ -22,7 +25,7 @@ @import '@/uni_modules/uview-ui/index.scss'; @font-face { font-family: siYuanLight; - src: url('https://mx.jzeg.cn:9095/appimg/fonts/siyuan.OTF'); + src: url('https://mx.jzeg.cn:9095/appimg/fonts/siyuannormal.OTF'); } @font-face { font-family: weighting; @@ -31,8 +34,4 @@ body { font-family: siYuanLight, sans-serif; } -// @font-face { -// font-family: 'weighting'; -// src: url('./utils/fonts/weighing.TTF'); -// } </style> diff --git a/manifest.json b/manifest.json index 9d4cb6c..47ae497 100644 --- a/manifest.json +++ b/manifest.json @@ -53,7 +53,7 @@ "appid": "wx4a62fc1684c429a9", "permission": { "scope.userFuzzyLocation": { - "desc": "浣犵殑浣嶇疆淇℃伅灏嗙敤浜庡皬绋嬪簭浣嶇疆鎺ュ彛鐨勬晥鏋滃睍绀�" + "desc": "浣犵殑浣嶇疆淇℃伅灏嗙敤浜庡皬绋嬪簭瀹氫綅" } }, "optimization": { diff --git a/pages.json b/pages.json index 417aa1a..a92a011 100644 --- a/pages.json +++ b/pages.json @@ -189,17 +189,15 @@ "enablePullDownRefresh": false } + }, { + "path": "pages/customer-page/customer-my/userMange/userManageEdit/userManageEdit", + "style": { + "navigationBarTitleText": "", + "enablePullDownRefresh": false + } + } - ,{ - "path" : "pages/customer-page/customer-my/userMange/userManageEdit/userManageEdit", - "style" : - { - "navigationBarTitleText": "", - "enablePullDownRefresh": false - } - - } - ], + ], "subPackages": [{ "root": "pages/register", "pages": [{ @@ -215,7 +213,8 @@ "path": "forward/forward", "style": { "navigationBarTitleText": "杞彂", - "enablePullDownRefresh": false + "enablePullDownRefresh": false, + "navigationStyle": "custom" } }, { "path": "message/message", @@ -234,11 +233,20 @@ }, { "path": "faYunstatisticsDetails/faYunstatisticsDetails", "style": { - "navigationBarTitleText": "", + "navigationBarTitleText": "鍙戣繍璇︽儏", "enablePullDownRefresh": false } - }] + } ,{ + "path" : "mapRoute/mapRoute", + "style" : + { + "navigationBarTitleText": "", + "enablePullDownRefresh": false + } + + } + ] }, { "root": "pages/driver-page/appointment", "pages": [{ diff --git a/pages/customer-page/customer-index/fayunPlanDetails/fayunPlanDetails.vue b/pages/customer-page/customer-index/fayunPlanDetails/fayunPlanDetails.vue index f3896fb..8ace7d0 100644 --- a/pages/customer-page/customer-index/fayunPlanDetails/fayunPlanDetails.vue +++ b/pages/customer-page/customer-index/fayunPlanDetails/fayunPlanDetails.vue @@ -7,7 +7,10 @@ <view class="top-title">鍙戣繍璁″垝璇︽儏</view> </view> <view class="middle-container"> - <view class="dept-name" v-show="deptName">{{ deptName }}({{ coalName }})</view> + <view class="dept-name"> + {{ deptName }} + <text v-show="deptName">({{ coalName }})</text> + </view> <view class="dept-num"> <text style="font-size: 46rpx; @@ -54,7 +57,7 @@ </view> </view> <view class="block-top"> - <combined-title title="鎻愮叅鍗曡鎯�"></combined-title> + <combined-title title="鎻愮叅鍗曞巻鍙�"></combined-title> <view class="total"> 鎬诲噣閲� <text>{{ total || 0 }}</text> @@ -64,7 +67,7 @@ <view class="empty-pointer" v-if="!yyDailyList">鏆傛棤鏇村鏁版嵁</view> <view class="main-block"> <view class="main-container"> - <view class="main-container_content" v-for="(item, index) in yyDailyList" :key="index" @click="showMore(index)"> + <view class="main-container_content" v-for="(item, index) in yyDailyList" :key="index" @click="showMore(item)"> <view class="arrow-icon"><u-icon name="arrow-right" size="30" color="#999999"></u-icon></view> <view class="divider"><u-divider></u-divider></view> <view class="first-line"> @@ -127,9 +130,9 @@ delta: 1 }); }, - showMore(index) { + showMore(item) { uni.navigateTo({ - url: `/pages/customer-page/customer-index/fayunPlanDetails/fayunPlanMore/fayunPlanMore?orderPlanId=${this.orderPlanId}&index=${index}` + url: `/pages/customer-page/customer-index/fayunPlanDetails/fayunPlanMore/fayunPlanMore?orderPlanId=${this.orderPlanId}&id=${item.id}` }); }, init() { @@ -214,6 +217,7 @@ position: relative; top: vww(54); .dept-name { + min-width: 100rpx; font-size: 32rpx; font-weight: normal; color: #ffffff; diff --git a/pages/customer-page/customer-index/fayunPlanDetails/fayunPlanMore/fayunPlanMore.vue b/pages/customer-page/customer-index/fayunPlanDetails/fayunPlanMore/fayunPlanMore.vue index b4388cb..bd64aac 100644 --- a/pages/customer-page/customer-index/fayunPlanDetails/fayunPlanMore/fayunPlanMore.vue +++ b/pages/customer-page/customer-index/fayunPlanDetails/fayunPlanMore/fayunPlanMore.vue @@ -23,25 +23,25 @@ <view class="body-container"> <view class="container-block"> <view class="">鐨噸</view> - <view class="">{{ yyDailyList.skin || '' }}</view> + <view class="">{{ yyDailyList.skin || 0 }}</view> </view> </view> <view class="body-container"> <view class="container-block"> <view class="">姣涢噸</view> - <view class="">{{ yyDailyList.hair || '' }}</view> + <view class="">{{ yyDailyList.hair || 0 }}</view> </view> </view> <view class="body-container"> <view class="container-block"> <view class="">鍑�閲�</view> - <view class="">{{ yyDailyList.clean || '' }}</view> + <view class="">{{ yyDailyList.clean || 0 }}</view> </view> </view> <view class="body-container"> <view class="container-block"> <view class="">璁㈠崟鍓╀綑閲�</view> - <view class="">{{ yyDailyList.allowance || '' }}</view> + <view class="">{{ yyDailyList.allowance || 0 }}</view> </view> </view> <view class="body-container"> @@ -57,6 +57,27 @@ </view> </view> </view> + <view class="origin-info" v-if="yyDailyList.orderType == '澶栬喘' || yyDailyList.orderType == '鍐呰喘' || yyDailyList.orderType == '杞嚭'"> + <combined-title title="鍘熷彂淇℃伅"></combined-title> + <view class="body-container"> + <view class="container-block"> + <view class="">鐨噸</view> + <view class="">{{ yyDailyList.skinTwo || 0 }}</view> + </view> + </view> + <view class="body-container"> + <view class="container-block"> + <view class="">姣涢噸</view> + <view class="">{{ yyDailyList.hairTwo || 0 }}</view> + </view> + </view> + <view class="body-container"> + <view class="container-block"> + <view class="">鍑�閲�</view> + <view class="">{{ yyDailyList.cleanTwo || 0 }}</view> + </view> + </view> + </view> </view> </view> </template> @@ -69,15 +90,14 @@ combinedTitle }, onLoad(params) { - this.orderPlanId = params.orderPlanId; - this.index = params.index; + this.id = params.id; }, onShow() { this.GetOrderPlanDetail(); }, data() { return { - orderPlanId: '', + id: '', yyDailyList: {}, orderPlanDetail: {}, coalStatus: ['棰嗗彇', '棰勭害', '绛惧埌', '鍏ュ満', '绉扮毊', '绉版瘺', '绂诲満', '鍏ョ鎴�', '鍑虹鎴�', '鍏ョ叅浠�', '鍑虹叅浠�', '鏀剧┖', '浣滃簾', '鍏ュ満鐢宠', '杩涘叆鍦洪櫌'], @@ -89,10 +109,10 @@ uni.showLoading({ title: '鍔犺浇涓�...' }); - this.$reqGet('xiangqingList', { orderPlanId: this.orderPlanId }).then(res => { + this.$reqGet('getTakeCoal', { takeCoalId: this.id }).then(res => { if (res.code == 0) { this.orderPlanDetail = res.data; - this.yyDailyList = res.data.yyDailyList.filter((v, i) => i == this.index)[0]; + this.yyDailyList = res.data; console.log(this.yyDailyList); uni.hideLoading(); } else { @@ -113,7 +133,9 @@ .main { width: 100%; margin-top: vww(10); - @include flex justify-content: center; + color: #303030; + @include flex; + flex-direction: column; .main-body { width: 690rpx; height: 1062rpx; @@ -123,6 +145,7 @@ @include flex flex-direction: column; align-items: flex-start; .body-container { + color: #303030; width: 100%; height: vww(56); border-bottom: vww(1) solid #d6d6d6; @@ -138,27 +161,27 @@ border-bottom: none; } } -} -.uni-table { - .uni-table-tr { - padding: 0; - border: vww(1) solid #c6c6c6; - .uni-table-th { - font-size: vww(14); - height: vww(30); - line-height: vww(30); - padding: vww(5) vww(10); - color: #111111; - font-weight: 500; - background: #e2e2e2; - } - .uni-table-td { - font-size: vww(14); - font-weight: 400; - height: vww(30); - line-height: vww(30); - padding: vww(5) vww(10); - color: #111111; + .origin-info { + width: 690rpx; + min-height: 300rpx; + margin-top: 20rpx; + margin-bottom: 20rpx; + background: #ffffff; + box-shadow: 0rpx 0rpx 14rpx 0rpx rgba(73, 120, 240, 0.14), 0rpx 7rpx 45rpx 0rpx rgba(73, 120, 240, 0.12); + border-radius: 20rpx; + @include flex; + flex-direction: column; + align-items: flex-start; + .body-container { + width: 100%; + height: vww(56); + border-bottom: vww(1) solid #d6d6d6; + @include flex; + justify-content: center; + .container-block { + width: 94%; + @include flex; + } } } } diff --git a/pages/customer-page/customer-my/faYunstatistics/faYunstatistics.vue b/pages/customer-page/customer-my/faYunstatistics/faYunstatistics.vue index 786fab1..da4f78a 100644 --- a/pages/customer-page/customer-my/faYunstatistics/faYunstatistics.vue +++ b/pages/customer-page/customer-my/faYunstatistics/faYunstatistics.vue @@ -40,7 +40,19 @@ </view> <view class="card-main" v-for="(value, i) in item.taskCoalList" :key="i" @click="faYunDetail(value.id)"> <view class="first-line"> - <view class="dispatch-receive"> + <view class="main-information"> + <view class="sign">瑁�</view> + <view class="filedname"> + <text v-if="value.orderType == '澶栭攢' || value.orderType == '鍐呴攢' || value.orderType == '杞嚭'">{{ value.deptName.slice(0, 16) }}</text> + <text v-else-if="value.orderType == '澶栬喘' || value.orderType == '鍐呰喘' || value.orderType == '杞叆'"> + {{ value.customerName.slice(0, 16) }} + </text> + <text v-show="value.deptName.length >= 15 || value.customerName.length >= 15">...</text> + </view> + </view> + <view class="main-divider"></view> + <view class="point-number">{{ value.clean.toFixed(2) || 0 }}</view> + <!-- <view class="dispatch-receive"> <view v-if="value.orderType == '澶栭攢' || value.orderType == '鍐呴攢' || value.orderType == '杞嚭'" class="container"> <view class="dispatch">{{ value.deptName }}</view> <view class="receive-icon"></view> @@ -51,8 +63,22 @@ <view class="receive-icon"></view> <view class="receive">{{ value.deptName }}</view> </view> + </view> --> + <!-- <view class="point-number">{{ value.clean.toFixed(2) || 0 }}</view> --> + </view> + <view class="first-extra"> + <view class="main-information"> + <view class="sign">鍗�</view> + <view class="filedname"> + <text v-if="value.orderType == '澶栭攢' || value.orderType == '鍐呴攢' || value.orderType == '杞嚭'"> + {{ value.customerName.slice(0, 16) }} + </text> + <text v-else-if="value.orderType == '澶栬喘' || value.orderType == '鍐呰喘' || value.orderType == '杞叆'"> + {{ value.deptName.slice(0, 16) }} + </text> + <text v-show="value.customerName.length >= 15 || value.deptName.length >= 15">...</text> + </view> </view> - <view class="point-number">{{ value.clean.toFixed(2) || 0 }}</view> </view> <view class="second-line"> <view class="coal-name"> @@ -600,6 +626,13 @@ justify-content: space-between; align-items: center; } +@mixin firstLine { + width: 80%; + height: vww(68); + margin: vww(10) vww(16) 0 0; + display: flex; + justify-content: space-between; +} ::v-deep .toggle-button .u-button { width: vww(40); } @@ -752,7 +785,7 @@ } .card-main { width: 100%; - height: vww(120); + height: vww(150); border-bottom: vww(1) solid #d6d6d6; margin-top: vww(12); padding-bottom: vww(12); @@ -760,45 +793,71 @@ @include flex flex-direction: column; align-items: flex-start; .first-line { - width: 94%; + width: 80%; height: vww(32); color: #303030; display: flex; justify-content: space-between; align-items: center; - .dispatch-receive { - width: 90%; + .main-information { + width: 88%; + height: vww(28); display: flex; - justify-content: space-between; + justify-content: flex-start; align-items: center; - margin-right: vww(12); - .container { - width: 100%; - display: flex; - justify-content: space-between; - align-items: center; + .sign { + width: vww(28); + height: vww(28); + line-height: vww(28); + text-align: center; + background: url('https://mx.jzeg.cn:9095/appimg/image/banner/blueblock.png') no-repeat; + background-size: contain; + font-size: 30rpx; + font-weight: 400; + color: #ffffff; + margin-right: vww(20); } - .receive-icon { - width: 62rpx; - height: 14rpx; - border-bottom: 3px solid #275fa5; - position: relative; - &:after { - content: ''; - position: absolute; - width: 3px; - height: 10px; - background-color: #275fa5; - right: 0; - transform: rotate(-45deg); - } - } + } + .main-divider { + width: 548rpx; + height: 1rpx; + background: #e3e3e3; + position: absolute; + top: 80rpx; + left: vww(50); } .point-number { width: 20%; font-size: 40rpx; font-weight: 400; color: #f81414; + position: absolute; + right: -10rpx; + display: flex; + flex-wrap: wrap; + } + } + .first-extra { + @include firstLine; + height: vww(32); + .main-information { + width: 100%; + height: vww(28); + display: flex; + justify-content: flex-start; + align-items: center; + .sign { + width: vww(28); + height: vww(28); + line-height: vww(28); + text-align: center; + background: url('https://mx.jzeg.cn:9095/appimg/image/banner/redblock.png') no-repeat; + background-size: contain; + font-size: 30rpx; + font-weight: 400; + color: #ffffff; + margin-right: vww(20); + } } } .second-line { diff --git a/pages/driver-page/driver-index/bill-of-lading-details/bill-of-lading-details.vue b/pages/driver-page/driver-index/bill-of-lading-details/bill-of-lading-details.vue index 5700c82..253db2c 100644 --- a/pages/driver-page/driver-index/bill-of-lading-details/bill-of-lading-details.vue +++ b/pages/driver-page/driver-index/bill-of-lading-details/bill-of-lading-details.vue @@ -19,7 +19,7 @@ style="background: url('https://mx.jzeg.cn:9095/appimg/image/banner/statusbutton.png') no-repeat; background-size: cover;" > - {{ coalStatus[coalDetailsData.status] }} + {{ coalStatus[coalDetailsData.status] || '' }} </view> </view> <view class="time"> @@ -27,7 +27,7 @@ <view class="send-date">{{ coalDetailsData.sendDate }}</view> </view> <view class="coal-code">鎻愮叅鍗曠紪鍙�: {{ coalDetailsData.code || '' }}</view> - <view class="order-code">璁㈠崟缂栧彿: {{ coalDetailsData.orderCode || '' }}</view> + <view class="order-code">璁㈠崟缂栧彿: {{ coalDetailsData.orderCode || '' }}</view> <view class="weigh-item"> <view class="item"> <view class="concrete" style="background: url('https://mx.jzeg.cn:9095/appimg/image/banner/skin.png') no-repeat;background-size: cover;">鐨�</view> @@ -58,7 +58,7 @@ <u-button text="鍏ュ満鐢宠" type="primary" plain @click="rcsqClick" shape="circle"></u-button> </view> <view class="bottom-button"> - <u-button text="鏀剧┖" type="primary" plain @click="evacuation" throttleTime="500" shape="circle"></u-button> + <u-button text="鏀剧┖" type="primary" plain @click="evacuation" throttleTime="500" shape="circle" :disabled="!isEvacuation"></u-button> <u-button text="鍛煎彨瀹㈡湇" type="primary" plain @click="callCustomerService" shape="circle"></u-button> </view> </view> @@ -163,6 +163,10 @@ let date = time.getDate(); date = date < 10 ? '0' + date : date; return `${year}-${month}-${date}`; + }, + // + isEvacuation() { + return this.coalDetailsData.hair == 0 || this.coalDetailsData.skin == 0; } }, methods: { diff --git a/pages/driver-page/driver-index/bill-of-lading-details/coal-pick-up-bill/coal-pick-up-bill.vue b/pages/driver-page/driver-index/bill-of-lading-details/coal-pick-up-bill/coal-pick-up-bill.vue index e0b8b83..dc142ea 100644 --- a/pages/driver-page/driver-index/bill-of-lading-details/coal-pick-up-bill/coal-pick-up-bill.vue +++ b/pages/driver-page/driver-index/bill-of-lading-details/coal-pick-up-bill/coal-pick-up-bill.vue @@ -75,39 +75,43 @@ color: #896227; } &-coalTwo { + width: 84%; margin-top: 20%; + margin: 20% auto 0; font-size: vww(20); font-weight: 700; text-align: center; color: #2e363f; view:nth-child(2) { margin-top: vww(15); - font-size: 40px; + font-size: 30px; } view:nth-child(3) { margin-top: vww(15); - font-size: 40px; + font-size: 30px; } view:nth-child(4) { margin-top: vww(15); - font-size: 40px; + font-size: 30px; } } &-coalThree { - margin-top: vww(46); + margin-top: vww(15); font-size: vww(18); font-weight: 700; text-align: center; color: #2e363f; view:nth-child(2) { - margin-top: vww(8); + margin-top: vww(15); } } &-coalFour { display: flex; justify-content: center; align-items: center; - margin-top: vww(78); + position: absolute; + bottom: 161rpx; + left: 42.5%; image { width: vww(52); height: vww(52); diff --git a/pages/driver-page/driver-index/bill-of-lading-details/weighingDevice/weighingDevice.vue b/pages/driver-page/driver-index/bill-of-lading-details/weighingDevice/weighingDevice.vue index 0515852..138a077 100644 --- a/pages/driver-page/driver-index/bill-of-lading-details/weighingDevice/weighingDevice.vue +++ b/pages/driver-page/driver-index/bill-of-lading-details/weighingDevice/weighingDevice.vue @@ -39,21 +39,35 @@ <view class="first-line"><combined-title title="鍘熷彂淇℃伅"></combined-title></view> <view class="second-line"> <view class="label-text" :class="{ focusClass: isfocus1 }">鐨噸</view> - <view class="input-container" :class="{ inputClass: isfocus1 }"> - <u--input placeholder="璇疯緭鍏ョ毊閲�" border="surround" v-model="weighData.coalContactSkin" @focus="inputFocus(1)" @blur="inputBlur"></u--input> + <view class="input-container" :class="{ inputClass: isfocus1, disabledClass: isInputOrigin }"> + <u--input + placeholder="璇疯緭鍏ョ毊閲�" + border="surround" + v-model="weighData.coalContactSkin" + @focus="inputFocus(1)" + @blur="inputBlur" + :disabled="isInputOrigin" + ></u--input> </view> <view class="unit" :class="{ focusClass: isfocus1 }">鍚�</view> </view> <view class="second-line"> <view class="label-text" :class="{ focusClass: isfocus2 }">姣涢噸</view> - <view class="input-container" :class="{ inputClass: isfocus2 }"> - <u--input placeholder="璇疯緭鍏ユ瘺閲�" border="surround" v-model="weighData.coalContactHair" @focus="inputFocus(2)" @blur="inputBlur"></u--input> + <view class="input-container" :class="{ inputClass: isfocus2, disabledClass: isInputOrigin }"> + <u--input + placeholder="璇疯緭鍏ユ瘺閲�" + border="surround" + v-model="weighData.coalContactHair" + @focus="inputFocus(2)" + @blur="inputBlur" + :disabled="isInputOrigin" + ></u--input> </view> <view class="unit" :class="{ focusClass: isfocus2 }">鍚�</view> </view> <view class="second-line"> <view class="label-text">鍑�閲�</view> - <view class="input-container"><u--input placeholder="璇疯緭鍏ュ噣閲�" border="surround" v-model="coalContactClean"></u--input></view> + <view class="input-container"><u--input placeholder="鍑�閲�" border="surround" v-model="coalContactClean" :disabled="isInputOrigin"></u--input></view> <view class="unit">鍚�</view> </view> </view> @@ -75,7 +89,7 @@ </view> </view> </view> - <view v-else style="width: 100%;height: vww(20);"></view> + <view v-else style="width: 100%;height: 40rpx;"></view> <view class="bottom-block"> <view class="block-main"> <view class="main-information"> @@ -119,14 +133,14 @@ <u-button type="primary" text="纭畾绉伴噸" - :disabled="realTimeWeigh == 0 || globalinfraredStatus || isweigh" + :disabled="realTimeWeigh == 0 || globalinfraredStatus || isweigh || isInputOrigin" :loading="isConfirmWeighLoading" loadingText="纭" @click="confirmWeigh" ></u-button> - <u-button type="primary" text="杩斿洖鍔犲噺鍚�" :disabled="addAndSubtractCoalDisabled" @click="addAndSubtractCoal" class="jiajian"></u-button> + <u-button type="primary" text="杩斿洖鍔犲噺鍚�" :disabled="addAndSubtractCoalDisabled" @click="addAndSubtractCoal" class="jiajian" v-if="outBuy"></u-button> </view> - <view class="four" v-if="weighList.orderType !== '澶栬喘'">濡傛偍闇�瑕佽皟鏁磋杞借揣鍝佸惃鏁帮紝璇风偣鍑昏繑鍥炲姞鍑忓惃</view> + <!-- <view class="four" v-if="weighList.orderType !== '澶栬喘'">濡傛偍闇�瑕佽皟鏁磋杞借揣鍝佸惃鏁帮紝璇风偣鍑昏繑鍥炲姞鍑忓惃</view> --> <!-- 鏀剧┖寮圭獥 --> <view class="evacuationModal"> <u-modal @@ -179,6 +193,8 @@ coalContactHair: 0, coalContactSkin: 0 }, + // 鏄惁濉啓鍘熷彂淇℃伅 + isInputOrigin: false, takeCoalId: null, weighHouseCode: '', isConfirmWeighLoading: false, //纭畾绉伴噸鎸夐挳 @@ -207,7 +223,9 @@ coalContactSkin: '', // 鑱氱劍鏃舵敼鍙樻牱寮� isfocus1: false, - isfocus2: false + isfocus2: false, + // 澶栬喘绗竴娆$О姣涢噸涓嶉渶瑕佸姞鍑忓惃 + outBuy: true }; }, watch: { @@ -239,11 +257,11 @@ // 鐩戝惉閲嶉噺鍙樺寲 globalweigh: { handler(v) { - // this.weighData.weigh = this.realTimeWeigh = v; - // console.log(this.realTimeWeigh, '鐪熷疄閲嶉噺鏀瑰彉浜�'); - setTimeout(() => { - this.weighData.weigh = this.realTimeWeigh = v; - }, 0); + this.weighData.weigh = this.realTimeWeigh = v; + console.log(this.realTimeWeigh, '鐪熷疄閲嶉噺鏀瑰彉浜�'); + // setTimeout(() => { + // this.weighData.weigh = this.realTimeWeigh = v; + // }, 0); }, deep: true, immediate: true @@ -299,8 +317,16 @@ this.weighData.carNo = res.data.carNo; this.weighData.tmCode = res.data.code; this.weighData.filedId = res.data.filedId; - if (this.weighList.orderType == '澶栬喘' && this.weighList.hair == 0) { + this.weighData.coalContactHair = res.data.hairTwo ? res.data.hairTwo : 0; + this.weighData.coalContactSkin = res.data.skinTwo ? res.data.skinTwo : 0; + if (this.weighList.orderType == '澶栬喘') { this.firstHairCustomernameShow = true; + if (this.weighList.hair == 0) { + this.outBuy = false; + } + } + if (this.weighData.coalContactHair > 0 && this.weighData.coalContactSkin > 0) { + this.isInputOrigin = true; } } }); @@ -493,6 +519,9 @@ box-shadow: 0rpx 5rpx 13rpx 0rpx rgba(73, 95, 252, 0.6) !important; border-radius: 12rpx !important; } + .isInputOrigin { + background-color: #f4f4fc; + } .input-container { border: 2px solid #c5c5c5; box-shadow: 0rpx 5rpx 13rpx 0rpx #c5c5c5; @@ -593,8 +622,9 @@ } } .four { - margin: vww(10) auto; - flex: 0.5; + width: 100%; + margin-top: vww(5); + text-align: center; } } .secondary-confirmation__main { diff --git a/pages/driver-page/driver-index/driver-index.vue b/pages/driver-page/driver-index/driver-index.vue index 498ea06..12a9ef6 100644 --- a/pages/driver-page/driver-index/driver-index.vue +++ b/pages/driver-page/driver-index/driver-index.vue @@ -2,41 +2,39 @@ <view class=""> <view class="driver-index"> <view class="driver-index-body"> - <!-- <combined-title title="寰呴鍙�"></combined-title> --> - <!-- <u-empty - mode="data" - icon="http://cdn.uviewui.com/uview/empty/data.png" - textSize="30" - iconSize="1000" - v-if="driverBillOfLoadingData.list1 ? (driverBillOfLoadingData.list1.length == 0 ? true : false) : true" - ></u-empty> --> - <!-- 寰呴鍙栨彁鐓ゅ崟 --> <view class="wait-collection" style="background: url('https://mx.jzeg.cn:9095/appimg/image/banner/diverbanner.png') no-repeat;background-size:contain"></view> <view class="collection-form"> <view class="collection-form-item" v-for="(item, index) in driverBillOfLoadingData.list1" :key="index"> <view class="first-line"> - <view class="dispatch-receive"> - <view v-if="item.orderType == '澶栭攢' || item.orderType == '鍐呴攢' || item.orderType == '杞嚭'" class="container"> - <view class="dispatch">{{ item.deptName || '' }}</view> - <view class="receive-icon"></view> - <view class="receive">{{ item.customerNameCopy || '' }}}</view> - </view> - <view v-else-if="item.orderType == '澶栬喘' || item.orderType == '鍐呰喘' || item.orderType == '杞叆'" class="container"> - <view class="dispatch">{{ item.customerNameCopy || '' }}</view> - <view class="receive-icon"></view> - <view class="receive">{{ item.deptName || '' }}}</view> + <view class="main-information"> + <view class="sign">瑁�</view> + <view class="filedname"> + <text v-if="item.orderType == '澶栭攢' || item.orderType == '鍐呴攢' || item.orderType == '杞嚭'">{{ item.deptName.slice(0, 16) }}</text> + <text v-else-if="item.orderType == '澶栬喘' || item.orderType == '鍐呰喘' || item.orderType == '杞叆'"> + {{ item.customerNameCopy.slice(0, 16) }} + </text> + <text v-show="item.deptName.length >= 15 || item.customerNameCopy.length >= 15">...</text> </view> </view> + <view class="main-divider"></view> <view class="point-number"> <text class="residue">{{ item.carNum - item.taskNum }}</text> <text>/{{ item.carNum }}</text> </view> </view> + <view class="first-extra"> + <view class="main-information"> + <view class="sign">鍗�</view> + <view class="filedname"> + <text v-if="item.orderType == '澶栭攢' || item.orderType == '鍐呴攢' || item.orderType == '杞嚭'">{{ item.customerNameCopy.slice(0, 16) }}</text> + <text v-else-if="item.orderType == '澶栬喘' || item.orderType == '鍐呰喘' || item.orderType == '杞叆'">{{ item.deptName.slice(0, 16) }}</text> + <text v-show="item.customerNameCopy.length >= 15 || item.deptName.length >= 15">...</text> + </view> + </view> + </view> <view class="second-line"> <view class="coal-name">{{ item.coalName }}</view> - <!-- <view class="black-block"><view class="black-bar"></view></view> - <view class="coal-type">{{ item.orderType }}</view> --> </view> <view class="third-line"> <view class="time-icon"><u-icon name="clock" color="#515151" size="40"></u-icon></view> @@ -67,12 +65,15 @@ <view class="main-information"> <view class="sign">瑁�</view> <view class="filedname"> - <text v-if="item.orderType == '澶栭攢' || item.orderType == '鍐呴攢' || item.orderType == '杞嚭'">{{ item.deptName }}</text> - <text v-else-if="item.orderType == '澶栬喘' || item.orderType == '鍐呰喘' || item.orderType == '杞叆'">{{ item.customerName }}</text> + <text v-if="item.orderType == '澶栭攢' || item.orderType == '鍐呴攢' || item.orderType == '杞嚭'">{{ item.deptName.slice(0, 16) }}</text> + <text v-else-if="item.orderType == '澶栬喘' || item.orderType == '鍐呰喘' || item.orderType == '杞叆'"> + {{ item.customerName.slice(0, 16) }} + </text> + <text v-show="item.deptName.length >= 15 || item.customerName.length >= 15">...</text> </view> </view> <view class="main-divider"></view> - <view class="map-icon"> + <view class="map-icon" @click.stop="skipMap(item)"> <view><u-icon name="map" color="#4978F0" size="40"></u-icon></view> </view> </view> @@ -80,11 +81,12 @@ <view class="main-information"> <view class="sign">鍗�</view> <view class="filedname"> - <text v-if="item.orderType == '澶栭攢' || item.orderType == '鍐呴攢' || item.orderType == '杞嚭'">{{ item.customerName }}</text> - <text v-else-if="item.orderType == '澶栬喘' || item.orderType == '鍐呰喘' || item.orderType == '杞叆'">{{ item.deptName }}</text> + <text v-if="item.orderType == '澶栭攢' || item.orderType == '鍐呴攢' || item.orderType == '杞嚭'">{{ item.customerName.slice(0, 16) }}</text> + <text v-else-if="item.orderType == '澶栬喘' || item.orderType == '鍐呰喘' || item.orderType == '杞叆'">{{ item.deptName.slice(0, 16) }}</text> + <text v-show="item.deptName.length >= 15 || item.customerName.length >= 15">...</text> </view> </view> - <view class="map-icon"> + <view class="map-icon" @click.stop="skipMap(item)"> <view><u-icon name="map" color="#4978F0" size="40"></u-icon></view> </view> </view> @@ -119,12 +121,15 @@ <view class="main-information"> <view class="sign">瑁�</view> <view class="filedname"> - <text v-if="item.orderType == '澶栭攢' || item.orderType == '鍐呴攢' || item.orderType == '杞嚭'">{{ item.deptName }}</text> - <text v-else-if="item.orderType == '澶栬喘' || item.orderType == '鍐呰喘' || item.orderType == '杞叆'">{{ item.customerName }}</text> + <text v-if="item.orderType == '澶栭攢' || item.orderType == '鍐呴攢' || item.orderType == '杞嚭'">{{ item.deptName.slice(0, 16) }}</text> + <text v-else-if="item.orderType == '澶栬喘' || item.orderType == '鍐呰喘' || item.orderType == '杞叆'"> + {{ item.customerName.slice(0, 16) }} + </text> + <text v-show="item.deptName.length >= 15 || item.customerName.length >= 15">...</text> </view> </view> <view class="main-divider"></view> - <view class="map-icon"> + <view class="map-icon" @click.stop="skipMap(item)"> <view><u-icon name="map" color="#4978F0" size="40"></u-icon></view> </view> </view> @@ -132,11 +137,12 @@ <view class="main-information"> <view class="sign">鍗�</view> <view class="filedname"> - <text v-if="item.orderType == '澶栭攢' || item.orderType == '鍐呴攢' || item.orderType == '杞嚭'">{{ item.customerName }}</text> - <text v-else-if="item.orderType == '澶栬喘' || item.orderType == '鍐呰喘' || item.orderType == '杞叆'">{{ item.deptName }}</text> + <text v-if="item.orderType == '澶栭攢' || item.orderType == '鍐呴攢' || item.orderType == '杞嚭'">{{ item.customerName.slice(0, 16) }}</text> + <text v-else-if="item.orderType == '澶栬喘' || item.orderType == '鍐呰喘' || item.orderType == '杞叆'">{{ item.deptName.slice(0, 16) }}</text> + <text v-show="item.deptName.length >= 15 || item.customerName.length >= 15">...</text> </view> </view> - <view class="map-icon"> + <view class="map-icon" @click.stop="skipMap(item)"> <view><u-icon name="map" color="#4978F0" size="40"></u-icon></view> </view> </view> @@ -192,17 +198,21 @@ qiangDanOrderPlanId: null, fleetId: '', xsUserId: '', - customerId: '', - // 闆嗘垚楂樺痉鍦板浘 - amapPlugin: null, - key: 'e3106700a6225e6a25727d3a41fa54c5', - addressName: '' + customerId: '' }; }, onShow() { this.init(); }, methods: { + // 璺宠浆鍦板浘 + skipMap(val) { + uni.navigateTo({ + url: `/pages/public-page/mapRoute/mapRoute?customerId=${val.customerId}&filedId=${val.filedId}&orderType=${val.orderType}${ + val.toFiledId ? `&toFiledId=${val.toFiledId}` : '' + }` + }); + }, init() { this.qiangDanList(); }, @@ -362,7 +372,7 @@ top: vww(-120); .collection-form-item { width: vww(345); - height: vww(150); + height: vww(185); margin-top: vww(5); background: #ffffff; box-shadow: 4rpx 6rpx 25rpx 0rpx rgba(73, 120, 240, 0.15); @@ -377,38 +387,39 @@ margin: vww(18) vww(16) 0 vww(16); display: flex; justify-content: space-between; - .dispatch-receive { - width: 70%; + .main-information { + width: 88%; + height: vww(28); display: flex; - justify-content: space-between; + justify-content: flex-start; align-items: center; - .container { - width: 100%; - display: flex; - justify-content: space-between; - align-items: center; - } - .receive-icon { - width: 62rpx; - height: 14rpx; - border-bottom: 3px solid #275fa5; - position: relative; - &:after { - content: ''; - position: absolute; - width: 3px; - height: 10px; - background-color: #275fa5; - right: 0; - transform: rotate(-45deg); - } + .sign { + width: vww(28); + height: vww(28); + line-height: vww(28); + text-align: center; + background: url('https://mx.jzeg.cn:9095/appimg/image/banner/blueblock.png') no-repeat; + background-size: contain; + font-size: 30rpx; + font-weight: 400; + color: #ffffff; + margin-right: vww(20); } } + .main-divider { + width: 548rpx; + height: 1rpx; + background: #e3e3e3; + position: absolute; + top: 115rpx; + left: vww(50); + } .point-number { + position: absolute; + right: 0; width: 15%; text { font-size: 24rpx; - font-weight: 400; color: #c78a64; } @@ -416,6 +427,28 @@ font-size: 40rpx; font-weight: 400; color: #f81414; + } + } + } + .first-extra { + @include firstLine; + .main-information { + width: 100%; + height: vww(28); + display: flex; + justify-content: flex-start; + align-items: center; + .sign { + width: vww(28); + height: vww(28); + line-height: vww(28); + text-align: center; + background: url('https://mx.jzeg.cn:9095/appimg/image/banner/redblock.png') no-repeat; + background-size: contain; + font-size: 30rpx; + font-weight: 400; + color: #ffffff; + margin-right: vww(20); } } } @@ -441,7 +474,6 @@ min-width: vww(50); height: 30rpx; font-size: 30rpx; - font-weight: 300; color: #515151; position: relative; @@ -549,7 +581,8 @@ } } .second-line { - @include firstLine margin: 0; + @include firstLine; + margin: 0; margin-left: vww(16); .main-information { width: 100%; diff --git a/pages/public-page/faYunstatisticsDetails/faYunstatisticsDetails.vue b/pages/public-page/faYunstatisticsDetails/faYunstatisticsDetails.vue index a1e3497..2f19646 100644 --- a/pages/public-page/faYunstatisticsDetails/faYunstatisticsDetails.vue +++ b/pages/public-page/faYunstatisticsDetails/faYunstatisticsDetails.vue @@ -57,59 +57,37 @@ </view> </view> </view> + <view class="origin-info" v-if="faYunDetailobj.orderType == '澶栬喘' || faYunDetailobj.orderType == '鍐呰喘' || faYunDetailobj.orderType == '杞嚭'"> + <combined-title title="鍘熷彂淇℃伅"></combined-title> + <view class="body-container"> + <view class="container-block"> + <view class="">鐨噸</view> + <view class="">{{ faYunDetailobj.skinTwo || 0 }}</view> + </view> + </view> + <view class="body-container"> + <view class="container-block"> + <view class="">姣涢噸</view> + <view class="">{{ faYunDetailobj.hairTwo || 0 }}</view> + </view> + </view> + <view class="body-container"> + <view class="container-block"> + <view class="">鍑�閲�</view> + <view class="">{{ faYunDetailobj.cleanTwo || 0 }}</view> + </view> + </view> + </view> </view> </view> - <!-- <view> - <combined-title title="鍙戣繍璇︽儏"></combined-title> - <view class="compDetails"> - <uni-table border stripe emptyText="鏆傛棤鏇村鏁版嵁"> - <uni-tr> - <uni-th align="left">鎻愮叅鍗曠紪鍙�</uni-th> - <uni-td align="left">{{ faYunDetailobj.code || '' }}</uni-td> - </uni-tr> - <uni-tr> - <uni-th align="left">鎻愮叅鍗曠姸鎬�</uni-th> - <uni-td align="left">{{ coalStatus[faYunDetailobj.status] }}</uni-td> - </uni-tr> - <uni-tr> - <uni-th align="left">杞︾墝鍙�</uni-th> - <uni-td align="left">{{ faYunDetailobj.carNo || '' }}</uni-td> - </uni-tr> - <uni-tr> - <uni-th align="left">鍏ュ満鏃堕棿</uni-th> - <uni-td align="left">{{ faYunDetailobj.inTime || '' }}</uni-td> - </uni-tr> - <uni-tr> - <uni-th align="left">鍑哄満鏃堕棿</uni-th> - <uni-td align="left">{{ faYunDetailobj.outTime || '' }}</uni-td> - </uni-tr> - <uni-tr> - <uni-th align="left">鐨噸</uni-th> - <uni-td align="left">{{ faYunDetailobj.skin || 0 }}</uni-td> - </uni-tr> - <uni-tr> - <uni-th align="left">姣涢噸</uni-th> - <uni-td align="left">{{ faYunDetailobj.hair || 0 }}</uni-td> - </uni-tr> - <uni-tr> - <uni-th align="left">鍑�閲�</uni-th> - <uni-td align="left">{{ faYunDetailobj.clean || 0 }}</uni-td> - </uni-tr> - <uni-tr> - <uni-th align="left">璁㈠崟缂栧彿</uni-th> - <uni-td align="left">{{ faYunDetailobj.orderCode || '' }}</uni-td> - </uni-tr> - <uni-tr> - <uni-th align="left">璁㈠崟鍓╀綑閲�</uni-th> - <uni-td align="left">{{ faYunDetailobj.allowance || 0 }}</uni-td> - </uni-tr> - </uni-table> - </view> - </view> --> </template> <script> +import combinedTitle from '@/components/combined-title/combined-title.vue'; export default { + components: { + combinedTitle + }, data() { return { id: '', @@ -142,14 +120,16 @@ .main { width: 100%; margin-top: vww(10); - @include flex justify-content: center; + @include flex; + flex-direction: column; .main-body { width: 690rpx; height: 1062rpx; background: #ffffff; box-shadow: 0rpx 0rpx 14rpx 0rpx rgba(73, 120, 240, 0.14), 0rpx 7rpx 45rpx 0rpx rgba(73, 120, 240, 0.12); border-radius: 20rpx; - @include flex flex-direction: column; + @include flex; + flex-direction: column; align-items: flex-start; .body-container { width: 100%; @@ -167,27 +147,27 @@ border-bottom: none; } } -} -.uni-table { - .uni-table-tr { - padding: 0; - border: vww(1) solid #c6c6c6; - .uni-table-th { - font-size: vww(14); - height: vww(30); - line-height: vww(30); - padding: vww(5) vww(10); - color: #111111; - font-weight: 500; - background: #e2e2e2; - } - .uni-table-td { - font-size: vww(14); - font-weight: 400; - height: vww(30); - line-height: vww(30); - padding: vww(5) vww(10); - color: #111111; + .origin-info { + width: 690rpx; + min-height: 300rpx; + margin-top: 20rpx; + margin-bottom: 20rpx; + background: #ffffff; + box-shadow: 0rpx 0rpx 14rpx 0rpx rgba(73, 120, 240, 0.14), 0rpx 7rpx 45rpx 0rpx rgba(73, 120, 240, 0.12); + border-radius: 20rpx; + @include flex; + flex-direction: column; + align-items: flex-start; + .body-container { + width: 100%; + height: vww(56); + border-bottom: vww(1) solid #d6d6d6; + @include flex; + justify-content: center; + .container-block { + width: 94%; + @include flex; + } } } } diff --git a/pages/public-page/forward/forward.vue b/pages/public-page/forward/forward.vue index 40d8611..e3a5c3e 100644 --- a/pages/public-page/forward/forward.vue +++ b/pages/public-page/forward/forward.vue @@ -1,37 +1,59 @@ <template> <!-- 杞彂 --> <view class="forward"> - <view v-if="roleType == 1"><u-notice-bar :text="text" :fontSize="30" mode="link"></u-notice-bar></view> - <view v-else-if="roleType == 2"><u-notice-bar :text="text1" :fontSize="30" mode="link"></u-notice-bar></view> - <view class="forward-card" v-for="(val, index) in jhOrderPlanForwardList" :key="index"> - <u--form labelPosition="top" :model="forwardForm" ref="form1"> - <u-form-item label="杞彂瀵硅薄" labelWidth="20%" ref="item1" @click="forwardObjectClick(index)"> - <u--input v-model="val.name" placeholder="鐐瑰嚮閫夋嫨杞彂瀵硅薄" :readonly="true"></u--input> - </u-form-item> - <u-form-item label="杈撳叆鏁伴噺" labelWidth="20%" ref="item1"> - <view class="forward-card-amount"> - <view class="forward-card-amount-input"> - <u--input - v-model="val.carNum" - placeholder="璇疯緭鍏ヨ浆鍙戞暟閲�" - @input="debouncecarNumInput(index, val.carNum)" - @blur="blurInput(index, val.carNum)" - ></u--input> - </view> - <u-checkbox-group v-model="val.checkboxValue1" placement="column" @change="v => checkboxChange(v, index, val)"> - <u-checkbox :customStyle="{ marginBottom: '8px' }" size="30" labelSize="30" label="鍏ㄩ儴杞彂" name="鍏ㄩ儴杞彂" :disabled="val.ischecked"></u-checkbox> - </u-checkbox-group> - </view> - </u-form-item> - <u-form-item><u-button text="鍒犻櫎鏈粍" :hairline="false" type="error" @click="deleteGroup(index, val)"></u-button></u-form-item> - </u--form> + <view class="forward-banner"> + <view class="banner-block"> + <view class="arrow-left" @click="back"><u-icon name="arrow-left" size="40" color="#ffffff"></u-icon></view> + <view class="forward-text">杞彂</view> + </view> + </view> + <view v-if="roleType == 1" class="notice-bar"> + <u-notice-bar :text="text" :fontSize="30"></u-notice-bar> + <view class="notice-icon" style="background: url('../../../static/image/banner/notice.png') no-repeat;background-size: cover; width: 42rpx;height: 42rpx;"></view> + </view> + <view v-else-if="roleType == 2" class="notice-bar"><u-notice-bar :text="text1" :fontSize="30"></u-notice-bar></view> + <view class="card-main"> + <view class="card-block"> + <view class="forward-card" v-for="(val, index) in jhOrderPlanForwardList" :key="index"> + <u-swipe-action> + <u-swipe-action-item :options="options1" @click="deleteGroup(index, val)"> + <view class="card-content"> + <u--form labelPosition="left" :model="forwardForm" ref="form1"> + <u-form-item label="杞彂瀵硅薄" labelWidth="21%" ref="item1" @click="forwardObjectClick(index)"> + <u--input v-model="val.name" placeholder="鐐瑰嚮閫夋嫨杞彂瀵硅薄" :readonly="true" border="bottom"></u--input> + </u-form-item> + <u-form-item label="杈撳叆鏁伴噺" ref="item2" labelWidth="21%"> + <view class="forward-card-amount"> + <view class="forward-card-amount-input"> + <u--input + v-model="val.carNum" + placeholder="璇疯緭鍏ヨ浆鍙戞暟閲�" + @input="debouncecarNumInput(index, val.carNum)" + @blur="blurInput(index, val.carNum)" + border="bottom" + ></u--input> + </view> + <u-checkbox-group v-model="val.checkboxValue1" placement="column" @change="v => checkboxChange(v, index, val)"> + <u-checkbox size="30" shape="circle" labelSize="30" label="鍏ㄩ儴杞彂" name="鍏ㄩ儴杞彂" :disabled="val.ischecked"></u-checkbox> + </u-checkbox-group> + </view> + </u-form-item> + <!-- <u-form-item><u-button text="鍒犻櫎鏈粍" :hairline="false" type="error" @click="deleteGroup(index, val)"></u-button></u-form-item> --> + </u--form> + </view> + </u-swipe-action-item> + </u-swipe-action> + </view> + </view> + </view> + + <view class="utils-buttonGroup"> + <!-- 娣诲姞鎸夐挳 --> + <view class="AdddBtn"><u-button text="娣诲姞" :hairline="false" @click.stop="addForm" :disabled="whetherClick"></u-button></view> + <!-- 鎻愪氦鎸夐挳 --> + <view class="forwardBtn"><u-button text="鎻愪氦" :hairline="false" type="warning" @click.stop="submitForm" :disabled="whetherClick1"></u-button></view> </view> <!-- 澧炲姞鎸夐挳 --> - <view class="AdddBtn"> - <u-button text="娣诲姞" :hairline="false" type="primary" :customStyle="{ marginBottom: '8px' }" @click="addForm" :disabled="whetherClick"></u-button> - </view> - <!-- 鎸夐挳 --> - <view class="forwardBtn"><u-button text="鎻愪氦" :hairline="false" type="warning" @click="submitForm" :disabled="whetherClick1"></u-button></view> <!-- 閫夋嫨璐т唬鎴栬溅闃熷脊鍑烘 --> <view class="selectHuoDaiOrFleet-container"> @@ -146,7 +168,16 @@ // 涓汉杞彂鏁版嵁 personalForward: {}, whetherClick: false, - whetherClick1: false + whetherClick1: false, + // 婊戝姩鍗曞厓鏍奸厤缃� + options1: [ + { + text: '鍒犻櫎', + style: { + backgroundColor: '#FB0101' + } + } + ] }; }, onShow() { @@ -168,6 +199,12 @@ } }, methods: { + // 杩斿洖涓婁竴椤� + back() { + uni.navigateBack({ + delta: 1 + }); + }, init() { switch (this.roleType) { case 1: @@ -235,7 +272,7 @@ this.calculate(this.jhOrderPlanForwardList); } if (this.roleType == 2) { - this.jhOrderPlanForwardList[index].carNum = this.allrelay(this.forwardSurplus, this.jhOrderPlanForwardList[index].carNum); + this.jhOrderPlanForwardList[index].carNum = this.allrelay(this.carNumSurplusHuodai, this.jhOrderPlanForwardList[index].carNum); this.calculate(this.jhOrderPlanForwardList); } // 閫夋嫨涓�涓悗鍏朵綑绂佹澶嶉�� @@ -319,15 +356,26 @@ this.whetherClick1 = true; } } - return total; + if (this.roleType == 2) { + if (this.carNum >= total) { + this.carNumSurplusHuodai = this.carNum - total; + this.whetherClick = false; + this.whetherClick1 = false; + } else { + this.carNumSurplusHuodai = 0; + this.$u.toast('鍓╀綑鎻愮叅鍗曟暟閲忎笉瓒�'); + this.whetherClick = true; + this.whetherClick1 = true; + } + } }, debouncecarNumInput(index, value) { let time; let that = this; + that.$set(that.jhOrderPlanForwardList[index], 'carNum', Number(value)); return (function() { if (!time) { time = setTimeout(() => { - that.$set(that.jhOrderPlanForwardList[index], 'carNum', Number(value)); that.calculate(that.jhOrderPlanForwardList); time = null; }, 800); @@ -368,7 +416,7 @@ // 鍒犻櫎涓�缁勮〃鍗� deleteGroup(index, v) { let tempcarNum = v.carNum; - if (v.id && this.jhOrderPlanForwardList[index].carNum !== tempcarNum) { + if (v.id) { this.$reqPost('deleteForward', { id: v.id }, 'params').then(res => { if (res.code === 0) { this.jhOrderPlanForwardList.splice(index, 1); @@ -433,33 +481,125 @@ </script> <style lang="scss" scoped> -::v-deep.forward { - width: 90%; - margin: 0 auto; - - // 鍗$墖 - .forward-card { - margin-top: vww(10); - .notice-bar { - width: 100%; - height: vww(24); +@mixin flex { + display: flex; + justify-content: space-between; + align-items: center; +} +/deep/ .u-notice-bar { + background: rgba(255, 255, 255, 0.3) !important; + box-shadow: 0rpx 0rpx 5rpx 0rpx rgba(27, 103, 255, 0); + border-radius: 28rpx; + .u-notice__content { + text { + text-shadow: 3rpx 3rpx 8rpx #4784fe; + font-size: 24rpx; + color: #fd1446 !important; + font-weight: 400; } - .u-form { - .u-form-item { - .u-form-item__body { - .u-form-item__body__right { - .u-form-item__body__right__content { - .u-form-item__body__right__content__slot { - .forward-card-amount { - display: flex; - justify-content: space-between; - align-items: flex-end; - .forward-card-amount-input { - width: vww(245); + } +} +/deep/ .u-input { + border-bottom: 1px solid #c4c4c4; + width: 458rpx; +} +::v-deep.forward { + width: 100%; + margin: 0 auto; + .forward-banner { + width: 100%; + height: 430rpx; + background: linear-gradient(0deg, #ffffff 0%, #0055fe 100%); + @include flex; + justify-content: flex-start; + overflow: hidden; + .banner-block { + width: 50%; + @include flex; + position: relative; + top: -75rpx; + left: 32rpx; + .forward-text { + width: 80rpx; + font-size: 40rpx; + font-weight: 400; + color: #ffffff; + line-height: 69rpx; + } + } + } + .notice-bar { + width: 688rpx; + height: 56rpx; + margin: 0 auto; + position: relative; + top: -200rpx; + background: transparent; + .notice-icon { + position: absolute; + top: 21rpx; + left: 7rpx; + } + } + .card-main { + width: 100%; + @include flex; + justify-content: center; + position: relative; + top: -100rpx; + .card-block { + width: 690rpx; + @include flex; + flex-direction: column; + .forward-card { + margin-top: vww(10); + width: 690rpx; + height: 275rpx; + background: #ffffff; + box-shadow: 4rpx 6rpx 25rpx 0rpx rgba(73, 120, 240, 0.15); + border-radius: 20rpx; + .card-content { + width: 612rpx; + margin-left: 48rpx; + margin-top: 24rpx; + // margin: 56rpx 30rpx 70rpx 48rpx; + .u-form { + .u-form-item { + .u-form-item__body { + .u-form-item__body__left { + .u-form-item__body__left__content { + .u-form-item__body__left__content__label { + font-weight: 400 !important; + color: #898989 !important; + font-size: 30rpx !important; + } } } - .u-input { - border: 1px solid #dddddd; + .u-form-item__body__right { + .u-form-item__body__right__content { + .u-form-item__body__right__content__slot { + .forward-card-amount { + display: flex; + justify-content: space-between; + align-items: flex-end; + .forward-card-amount-input { + .u-input { + width: 263rpx; + } + } + .u-checkbox-group { + position: relative; + top: vww(8); + left: vww(4); + .u-checkbox { + .u-checkbox__icon-wrap { + border-color: rgba(42, 97, 255, 1) !important; + } + } + } + } + } + } } } } @@ -467,21 +607,41 @@ } } } - .forward-card-amount { - display: flex; + } + .utils-buttonGroup { + width: 610rpx; + @include flex; + position: fixed; + bottom: vww(50); + left: vww(25); + z-index: 2; + .AdddBtn, + .forwardBtn { + width: 290rpx; + } + .AdddBtn { + .u-button { + height: 74rpx; + border: 1px solid #3b56eb; + border-radius: 37rpx 37rpx 37rpx 37rpx; + background: transparent; + color: #3b56eb; + } + } + .forwardBtn { + .u-button { + height: 74rpx; + color: #ffffff; + background: rgba(73, 123, 251, 1); + border: 0; + border-radius: 37rpx 37rpx 37rpx 37rpx; + } } } - - .forwardBtn { - width: 100%; - // position: fixed; - bottom: vww(50); - } - .selectHuoDaiOrFleet-container { .u-popup { .u-transition { - height: 95%; + height: 80%; .u-popup__content { overflow: scroll !important; diff --git a/pages/public-page/mapRoute/mapRoute.vue b/pages/public-page/mapRoute/mapRoute.vue new file mode 100644 index 0000000..f686e1c --- /dev/null +++ b/pages/public-page/mapRoute/mapRoute.vue @@ -0,0 +1,223 @@ +<template> + <view> + <view class="page-body" style="margin-top: 4rpx;"> + <view class="page-section page-section-gap"> + <map style="width: 100%; height: 600px;" :latitude="latitude" :longitude="longitude" :markers="markers" :polyline="polyline"></map> + </view> + </view> + <view class="tip"> + <view class="first"> + 閫氳璺濈 + <text>{{ distance || '' }}Km</text> + </view> + <view class="first"> + 棰勮鍒拌揪鏃堕棿 + <text>{{ duration || '' }}</text> + </view> + </view> + </view> +</template> + +<script> +export default { + data() { + return { + latitude: 38.04606544104117, + longitude: 114.48735479816793, + customerId: '', + filedId: '', + orderType: '', + toFiledId: '', + // 璧风偣缁忕含搴� + originlongitude: 39.909, + originlatitude: 116.39742, + // 缁堢偣 + finishlongitude: null, + finishlatitude: null, + markers: [ + { + latitude: null, + longitude: null, + iconPath: '../../../static/image/banner/location.png', + width: 23, + height: 33, + id: 0, + callout: { + content: '璧风偣', //鏂囨湰 + color: '#ffffff', //鏂囧瓧棰滆壊 + fontSize: 14, //鏂囨湰澶у皬 + borderRadius: 15, //杈规鍦嗚 + borderWidth: '10', + bgColor: '#e51860', //鑳屾櫙棰滆壊 + display: 'ALWAYS' //甯告樉 + } + }, + { + latitude: null, + longitude: null, + iconPath: '../../../static/image/banner/location.png', + width: 23, + height: 33, + id: 1, + callout: { + content: '缁堢偣', //鏂囨湰 + color: '#ffffff', //鏂囧瓧棰滆壊 + fontSize: 14, //鏂囨湰澶у皬 + borderRadius: 15, //杈规鍦嗚 + borderWidth: '10', + bgColor: '#e51860', //鑳屾櫙棰滆壊 + display: 'ALWAYS' //甯告樉 + } + } + ], + polyline: [ + { + // 姣忎釜鐐圭殑缁忕含搴� + points: [{ latitude: 38.04606544104117, longitude: 114.48735479816793 }, { latitude: 38.049531, longitude: 114.53521899999998 }], + // 棰滆壊 + color: '#0091ff', + // 瀹藉害 + width: 10 + } + ], + distance: null, + duration: null + }; + }, + methods: { + getLocation() { + uni.showLoading({ + title: '鍔犺浇涓��' + }); + let QQMapWX = require('../../../utils/qqmap-wx-jssdk.js'); + let qqmapsdk = new QQMapWX({ + key: 'HTNBZ-LZGRQ-YDB5S-B4KAS-KLHJH-GHBUE' // 蹇呭~ + }); + const params = this.toFiledId ? { toFiledId: this.toFiledId } : { customerId: this.customerId, filedId: this.filedId }; + this.$reqGet('getAppLocation', params).then(res => { + console.log(res, '鑵捐缁忕含搴�'); + let _this = this; + let fromLocation; + let toLocation; + if (_this.orderType == '澶栬喘' || _this.orderType == '澶栭攢') { + _this.$set(_this.markers[0], 'longitude', res.data.customerLongitude); + _this.$set(_this.markers[0], 'latitude', res.data.customerLatitude); + fromLocation = { + longitude: res.data.customerLongitude, + latitude: res.data.customerLatitude + }; + _this.$set(_this.markers[1], 'longitude', res.data.filedLongitude); + _this.$set(_this.markers[1], 'latitude', res.data.filedLatitude); + toLocation = { + longitude: res.data.filedLongitude, + latitude: res.data.filedLatitude + }; + } else if (_this.orderType == '鍐呰喘' || _this.orderType == '鍐呴攢') { + _this.$set(_this.markers[0], 'longitude', res.data.filedLongitude); + _this.$set(_this.markers[0], 'latitude', res.data.filedLatitude); + fromLocation = { + longitude: res.data.filedLongitude, + latitude: res.data.filedLatitude + }; + _this.$set(_this.markers[1], 'longitude', res.data.customerLongitude); + _this.$set(_this.markers[1], 'latitude', res.data.customerLatitude); + toLocation = { + longitude: res.data.customerLongitude, + latitude: res.data.customerLatitude + }; + } + //璋冪敤璺濈璁$畻鎺ュ彛 + qqmapsdk.direction({ + mode: 'driving', + //from鍙傛暟涓嶅~榛樿褰撳墠鍦板潃 + from: fromLocation, + to: toLocation, + success: function(res) { + console.log(res); + let ret = res; + let coors = ret.result.routes[0].polyline, + pl = []; + //鍧愭爣瑙e帇锛堣繑鍥炵殑鐐逛覆鍧愭爣锛岄�氳繃鍓嶅悜宸垎杩涜鍘嬬缉锛� + let kr = 1000000; + for (let i = 2; i < coors.length; i++) { + coors[i] = Number(coors[i - 2]) + Number(coors[i]) / kr; + } + //灏嗚В鍘嬪悗鐨勫潗鏍囨斁鍏ョ偣涓叉暟缁刾l涓� + for (let i = 0; i < coors.length; i += 2) { + pl.push({ latitude: coors[i], longitude: coors[i + 1] }); + } + console.log(pl); + //璁剧疆polyline灞炴�э紝灏嗚矾绾挎樉绀哄嚭鏉�,灏嗚В鍘嬪潗鏍囩涓�涓暟鎹綔涓鸿捣鐐� + _this.longitude = pl[0].longitude; + _this.latitude = pl[0].latitude; + _this.polyline = [ + { + points: pl, + color: '#FF0000DD', + width: 4, + arrowLine: true + } + ]; + }, + fail: function(error) { + console.error(error); + }, + complete: function(res) { + console.log(res); + uni.hideLoading(); + _this.distance = res.result.routes[0].distance; + _this.distance = (_this.distance / 1000).toFixed(2); + _this.duration = _this.handleTime(res.result.routes[0].duration); + } + }); + }); + }, + // + handleTime(time) { + let now = new Date(); // 鑾峰彇褰撳墠鏃堕棿 + now.setMinutes(now.getMinutes() + time); + let hours = now + .getHours() + .toString() + .padStart(2, '0'); + let minutes = now + .getMinutes() + .toString() + .padStart(2, '0'); + return hours + ':' + minutes; + } + }, + onLoad(params) { + this.customerId = params.customerId; + this.filedId = params.filedId; + this.orderType = params.orderType; + if (params.toFiledId) { + this.toFiledId = params.toFiledId; + } + }, + onShow() { + if (this.orderType !== '杞叆' || this.orderType !== '杞嚭') { + this.getLocation(); + } else { + } + } +}; +</script> + +<style lang="scss" scoped> +.tip { + margin-top: 60rpx; + width: 94%; + height: 40rpx; + font-size: 40rpx; + display: flex; + justify-content: space-around; + .first { + color: #c78a64; + text { + font-size: 45rpx; + color: #f81414; + } + } +} +</style> diff --git a/pages/public-page/message/message.vue b/pages/public-page/message/message.vue index 21bebd4..592a6e4 100644 --- a/pages/public-page/message/message.vue +++ b/pages/public-page/message/message.vue @@ -63,10 +63,31 @@ if (res.code == 0) { uni.hideLoading(); this.total = res.data.total; + const regex = /<[^>]*>([^<]*)<\/[^>]*>/g; + + const solveHandle = v => { + const regex = /<[^>]*>([^<]*)<\/[^>]*>/g; + let result = v.replace(regex, (match, p1) => { + return p1.length > 8 ? p1.slice(0, 8) + '...' : p1; + }); + return result; + }; if (this.pageNum > 1) { this.messageList = this.messageList.concat(res.data.records); + this.messageList = this.messageList.map(v => { + return { + ...v, + content: solveHandle(v.content) + }; + }); } else if (this.pageNum == 1) { this.messageList = res.data.records; + this.messageList = this.messageList.map(v => { + return { + ...v, + content: solveHandle(v.content) + }; + }); } } else { this.$u.toast('鍔犺浇澶辫触'); diff --git a/pages/tabbar-page/index-tabbar/index-tabbar.vue b/pages/tabbar-page/index-tabbar/index-tabbar.vue index da810e4..b15ebb7 100644 --- a/pages/tabbar-page/index-tabbar/index-tabbar.vue +++ b/pages/tabbar-page/index-tabbar/index-tabbar.vue @@ -40,7 +40,10 @@ freightForwarderIndex }, computed: { - ...mapState(['globalweighHouseCode', 'globalweigh']) + ...mapState(['globalweighHouseCode', 'globalweigh', 'globalisconnect']) + }, + watch: { + globalisconnect(v, oldv) {} }, //棣栭〉涓嬫媺鍒锋柊 onPullDownRefresh() { @@ -111,18 +114,6 @@ console.log('寮�鍚弻浜洪�氳瘽鎴愬姛Complete'); } }); - let amap = require('../../../utils/amap-wx.130.js'); - let amapPlugin = new amap.AMapWX({ - key: 'e3106700a6225e6a25727d3a41fa54c5' - }); - amapPlugin.getRegeo({ - success: data => { - console.log(data, '鑾峰彇浣嶇疆'); - }, - fail: info => { - console.log(info, '閿欒淇℃伅'); - } - }); }, data() { return { @@ -134,15 +125,12 @@ messagePushShow: false, messageList: {}, isconnect: false, - dotShow: false, - amapPlugin: null, - key: 'e3106700a6225e6a25727d3a41fa54c5', - addressName: '' + dotShow: false }; }, onShow() { this.init(); - if (!this.isconnect) { + if (!this.globalisconnect || !this.isconnect) { this.initWebsocket(); } this.userAuthorization(); @@ -150,7 +138,10 @@ }, onHide() { console.log('椤甸潰闅愯棌'); - if (!this.isconnect) { + // this.isconnect = false; + // this.changeisconnect(false); + // socket.close(); + if (!this.globalisconnect || !this.isconnect) { this.initWebsocket(); } }, @@ -160,7 +151,7 @@ clearInterval(this.intervalId); }, methods: { - ...mapMutations(['pushMessage', 'changeWeigh', 'changeinfraredStatus']), + ...mapMutations(['pushMessage', 'changeWeigh', 'changeinfraredStatus', 'changeisconnect']), messagePage() { uni.navigateTo({ url: '/pages/public-page/message/message' @@ -239,6 +230,7 @@ complete: res => { console.log(res, 'socket缁撴灉'); if (res.errMsg == 'connectSocket:ok') { + this.changeisconnect(true); this.isconnect = true; } } diff --git a/static/image/banner/location.png b/static/image/banner/location.png new file mode 100644 index 0000000..75704ef --- /dev/null +++ b/static/image/banner/location.png Binary files differ diff --git a/static/image/banner/notice.png b/static/image/banner/notice.png new file mode 100644 index 0000000..e5b497f --- /dev/null +++ b/static/image/banner/notice.png Binary files differ diff --git a/store/index.js b/store/index.js index f6dcee1..77612ae 100644 --- a/store/index.js +++ b/store/index.js @@ -71,6 +71,7 @@ weight: '', userId: '' }, + globalisconnect: false }, mutations: { lengthchange(state, payload) { @@ -110,6 +111,10 @@ }, changeuserInfo(state, payload) { state.globaluserInfo = payload + }, + // 鏀圭増鍏ㄥ眬websocket鐘舵�� + changeisconnect(state, payload) { + state.globalisconnect = payload } } }) diff --git a/utils/amap-wx.130.js b/utils/amap-wx.130.js deleted file mode 100644 index 718d6ef..0000000 --- a/utils/amap-wx.130.js +++ /dev/null @@ -1,31 +0,0 @@ -function AMapWX(a){this.key=a.key;this.requestConfig={key:a.key,s:"rsx",platform:"WXJS",appname:a.key,sdkversion:"1.2.0",logversion:"2.0"};this.MeRequestConfig={key:a.key,serviceName:"https://restapi.amap.com/rest/me"}} -AMapWX.prototype.getWxLocation=function(a,b){wx.getLocation({type:"gcj02",success:function(c){c=c.longitude+","+c.latitude;wx.setStorage({key:"userLocation",data:c});b(c)},fail:function(c){wx.getStorage({key:"userLocation",success:function(d){d.data&&b(d.data)}});a.fail({errCode:"0",errMsg:c.errMsg||""})}})}; -AMapWX.prototype.getMEKeywordsSearch=function(a){if(!a.options)return a.fail({errCode:"0",errMsg:"\u7f3a\u5c11\u5fc5\u8981\u53c2\u6570"});var b=a.options,c=this.MeRequestConfig,d={key:c.key,s:"rsx",platform:"WXJS",appname:a.key,sdkversion:"1.2.0",logversion:"2.0"};b.layerId&&(d.layerId=b.layerId);b.keywords&&(d.keywords=b.keywords);b.city&&(d.city=b.city);b.filter&&(d.filter=b.filter);b.sortrule&&(d.sortrule=b.sortrule);b.pageNum&&(d.pageNum=b.pageNum);b.pageSize&&(d.pageSize=b.pageSize);b.sig&&(d.sig= -b.sig);wx.request({url:c.serviceName+"/cpoint/datasearch/local",data:d,method:"GET",header:{"content-type":"application/json"},success:function(e){(e=e.data)&&e.status&&"1"===e.status&&0===e.code?a.success(e.data):a.fail({errCode:"0",errMsg:e})},fail:function(e){a.fail({errCode:"0",errMsg:e.errMsg||""})}})}; -AMapWX.prototype.getMEIdSearch=function(a){if(!a.options)return a.fail({errCode:"0",errMsg:"\u7f3a\u5c11\u5fc5\u8981\u53c2\u6570"});var b=a.options,c=this.MeRequestConfig,d={key:c.key,s:"rsx",platform:"WXJS",appname:a.key,sdkversion:"1.2.0",logversion:"2.0"};b.layerId&&(d.layerId=b.layerId);b.id&&(d.id=b.id);b.sig&&(d.sig=b.sig);wx.request({url:c.serviceName+"/cpoint/datasearch/id",data:d,method:"GET",header:{"content-type":"application/json"},success:function(e){(e=e.data)&&e.status&&"1"===e.status&& -0===e.code?a.success(e.data):a.fail({errCode:"0",errMsg:e})},fail:function(e){a.fail({errCode:"0",errMsg:e.errMsg||""})}})}; -AMapWX.prototype.getMEPolygonSearch=function(a){if(!a.options)return a.fail({errCode:"0",errMsg:"\u7f3a\u5c11\u5fc5\u8981\u53c2\u6570"});var b=a.options,c=this.MeRequestConfig,d={key:c.key,s:"rsx",platform:"WXJS",appname:a.key,sdkversion:"1.2.0",logversion:"2.0"};b.layerId&&(d.layerId=b.layerId);b.keywords&&(d.keywords=b.keywords);b.polygon&&(d.polygon=b.polygon);b.filter&&(d.filter=b.filter);b.sortrule&&(d.sortrule=b.sortrule);b.pageNum&&(d.pageNum=b.pageNum);b.pageSize&&(d.pageSize=b.pageSize); -b.sig&&(d.sig=b.sig);wx.request({url:c.serviceName+"/cpoint/datasearch/polygon",data:d,method:"GET",header:{"content-type":"application/json"},success:function(e){(e=e.data)&&e.status&&"1"===e.status&&0===e.code?a.success(e.data):a.fail({errCode:"0",errMsg:e})},fail:function(e){a.fail({errCode:"0",errMsg:e.errMsg||""})}})}; -AMapWX.prototype.getMEaroundSearch=function(a){if(!a.options)return a.fail({errCode:"0",errMsg:"\u7f3a\u5c11\u5fc5\u8981\u53c2\u6570"});var b=a.options,c=this.MeRequestConfig,d={key:c.key,s:"rsx",platform:"WXJS",appname:a.key,sdkversion:"1.2.0",logversion:"2.0"};b.layerId&&(d.layerId=b.layerId);b.keywords&&(d.keywords=b.keywords);b.center&&(d.center=b.center);b.radius&&(d.radius=b.radius);b.filter&&(d.filter=b.filter);b.sortrule&&(d.sortrule=b.sortrule);b.pageNum&&(d.pageNum=b.pageNum);b.pageSize&& -(d.pageSize=b.pageSize);b.sig&&(d.sig=b.sig);wx.request({url:c.serviceName+"/cpoint/datasearch/around",data:d,method:"GET",header:{"content-type":"application/json"},success:function(e){(e=e.data)&&e.status&&"1"===e.status&&0===e.code?a.success(e.data):a.fail({errCode:"0",errMsg:e})},fail:function(e){a.fail({errCode:"0",errMsg:e.errMsg||""})}})}; -AMapWX.prototype.getGeo=function(a){var b=this.requestConfig,c=a.options;b={key:this.key,extensions:"all",s:b.s,platform:b.platform,appname:this.key,sdkversion:b.sdkversion,logversion:b.logversion};c.address&&(b.address=c.address);c.city&&(b.city=c.city);c.batch&&(b.batch=c.batch);c.sig&&(b.sig=c.sig);wx.request({url:"https://restapi.amap.com/v3/geocode/geo",data:b,method:"GET",header:{"content-type":"application/json"},success:function(d){(d=d.data)&&d.status&&"1"===d.status?a.success(d):a.fail({errCode:"0", -errMsg:d})},fail:function(d){a.fail({errCode:"0",errMsg:d.errMsg||""})}})}; -AMapWX.prototype.getRegeo=function(a){function b(d){var e=c.requestConfig;wx.request({url:"https://restapi.amap.com/v3/geocode/regeo",data:{key:c.key,location:d,extensions:"all",s:e.s,platform:e.platform,appname:c.key,sdkversion:e.sdkversion,logversion:e.logversion},method:"GET",header:{"content-type":"application/json"},success:function(g){if(g.data.status&&"1"==g.data.status){g=g.data.regeocode;var h=g.addressComponent,f=[],k=g.roads[0].name+"\u9644\u8fd1",m=d.split(",")[0],n=d.split(",")[1];if(g.pois&& -g.pois[0]){k=g.pois[0].name+"\u9644\u8fd1";var l=g.pois[0].location;l&&(m=parseFloat(l.split(",")[0]),n=parseFloat(l.split(",")[1]))}h.provice&&f.push(h.provice);h.city&&f.push(h.city);h.district&&f.push(h.district);h.streetNumber&&h.streetNumber.street&&h.streetNumber.number?(f.push(h.streetNumber.street),f.push(h.streetNumber.number)):f.push(g.roads[0].name);f=f.join("");a.success([{iconPath:a.iconPath,width:a.iconWidth,height:a.iconHeight,name:f,desc:k,longitude:m,latitude:n,id:0,regeocodeData:g}])}else a.fail({errCode:g.data.infocode, -errMsg:g.data.info})},fail:function(g){a.fail({errCode:"0",errMsg:g.errMsg||""})}})}var c=this;a.location?b(a.location):c.getWxLocation(a,function(d){b(d)})}; -AMapWX.prototype.getWeather=function(a){function b(g){var h="base";a.type&&"forecast"==a.type&&(h="all");wx.request({url:"https://restapi.amap.com/v3/weather/weatherInfo",data:{key:d.key,city:g,extensions:h,s:e.s,platform:e.platform,appname:d.key,sdkversion:e.sdkversion,logversion:e.logversion},method:"GET",header:{"content-type":"application/json"},success:function(f){if(f.data.status&&"1"==f.data.status)if(f.data.lives){if((f=f.data.lives)&&0<f.length){f=f[0];var k={city:{text:"\u57ce\u5e02",data:f.city}, -weather:{text:"\u5929\u6c14",data:f.weather},temperature:{text:"\u6e29\u5ea6",data:f.temperature},winddirection:{text:"\u98ce\u5411",data:f.winddirection+"\u98ce"},windpower:{text:"\u98ce\u529b",data:f.windpower+"\u7ea7"},humidity:{text:"\u6e7f\u5ea6",data:f.humidity+"%"}};k.liveData=f;a.success(k)}}else f.data.forecasts&&f.data.forecasts[0]&&a.success({forecast:f.data.forecasts[0]});else a.fail({errCode:f.data.infocode,errMsg:f.data.info})},fail:function(f){a.fail({errCode:"0",errMsg:f.errMsg||""})}})} -function c(g){wx.request({url:"https://restapi.amap.com/v3/geocode/regeo",data:{key:d.key,location:g,extensions:"all",s:e.s,platform:e.platform,appname:d.key,sdkversion:e.sdkversion,logversion:e.logversion},method:"GET",header:{"content-type":"application/json"},success:function(h){if(h.data.status&&"1"==h.data.status){h=h.data.regeocode;if(h.addressComponent)var f=h.addressComponent.adcode;else h.aois&&0<h.aois.length&&(f=h.aois[0].adcode);b(f)}else a.fail({errCode:h.data.infocode,errMsg:h.data.info})}, -fail:function(h){a.fail({errCode:"0",errMsg:h.errMsg||""})}})}var d=this,e=d.requestConfig;a.city?b(a.city):d.getWxLocation(a,function(g){c(g)})}; -AMapWX.prototype.getPoiAround=function(a){function b(e){e={key:c.key,location:e,s:d.s,platform:d.platform,appname:c.key,sdkversion:d.sdkversion,logversion:d.logversion};a.querytypes&&(e.types=a.querytypes);a.querykeywords&&(e.keywords=a.querykeywords);wx.request({url:"https://restapi.amap.com/v3/place/around",data:e,method:"GET",header:{"content-type":"application/json"},success:function(g){if(g.data.status&&"1"==g.data.status){if((g=g.data)&&g.pois){for(var h=[],f=0;f<g.pois.length;f++){var k=0== -f?a.iconPathSelected:a.iconPath;h.push({latitude:parseFloat(g.pois[f].location.split(",")[1]),longitude:parseFloat(g.pois[f].location.split(",")[0]),iconPath:k,width:22,height:32,id:f,name:g.pois[f].name,address:g.pois[f].address})}a.success({markers:h,poisData:g.pois})}}else a.fail({errCode:g.data.infocode,errMsg:g.data.info})},fail:function(g){a.fail({errCode:"0",errMsg:g.errMsg||""})}})}var c=this,d=c.requestConfig;a.location?b(a.location):c.getWxLocation(a,function(e){b(e)})}; -AMapWX.prototype.getStaticmap=function(a){function b(e){c.push("location="+e);a.zoom&&c.push("zoom="+a.zoom);a.size&&c.push("size="+a.size);a.scale&&c.push("scale="+a.scale);a.markers&&c.push("markers="+a.markers);a.labels&&c.push("labels="+a.labels);a.paths&&c.push("paths="+a.paths);a.traffic&&c.push("traffic="+a.traffic);e="https://restapi.amap.com/v3/staticmap?"+c.join("&");a.success({url:e})}var c=[];c.push("key="+this.key);var d=this.requestConfig;c.push("s="+d.s);c.push("platform="+d.platform); -c.push("appname="+d.appname);c.push("sdkversion="+d.sdkversion);c.push("logversion="+d.logversion);a.location?b(a.location):this.getWxLocation(a,function(e){b(e)})}; -AMapWX.prototype.getInputtips=function(a){var b=Object.assign({},this.requestConfig);a.location&&(b.location=a.location);a.keywords&&(b.keywords=a.keywords);a.type&&(b.type=a.type);a.city&&(b.city=a.city);a.citylimit&&(b.citylimit=a.citylimit);wx.request({url:"https://restapi.amap.com/v3/assistant/inputtips",data:b,method:"GET",header:{"content-type":"application/json"},success:function(c){c&&c.data&&c.data.tips&&a.success({tips:c.data.tips})},fail:function(c){a.fail({errCode:"0",errMsg:c.errMsg|| -""})}})}; -AMapWX.prototype.getDrivingRoute=function(a){var b=Object.assign({},this.requestConfig);a.origin&&(b.origin=a.origin);a.destination&&(b.destination=a.destination);a.strategy&&(b.strategy=a.strategy);a.waypoints&&(b.waypoints=a.waypoints);a.avoidpolygons&&(b.avoidpolygons=a.avoidpolygons);a.avoidroad&&(b.avoidroad=a.avoidroad);wx.request({url:"https://restapi.amap.com/v3/direction/driving",data:b,method:"GET",header:{"content-type":"application/json"},success:function(c){c&&c.data&&c.data.route&&a.success({paths:c.data.route.paths, -taxi_cost:c.data.route.taxi_cost||""})},fail:function(c){a.fail({errCode:"0",errMsg:c.errMsg||""})}})}; -AMapWX.prototype.getWalkingRoute=function(a){var b=Object.assign({},this.requestConfig);a.origin&&(b.origin=a.origin);a.destination&&(b.destination=a.destination);wx.request({url:"https://restapi.amap.com/v3/direction/walking",data:b,method:"GET",header:{"content-type":"application/json"},success:function(c){c&&c.data&&c.data.route&&a.success({paths:c.data.route.paths})},fail:function(c){a.fail({errCode:"0",errMsg:c.errMsg||""})}})}; -AMapWX.prototype.getTransitRoute=function(a){var b=Object.assign({},this.requestConfig);a.origin&&(b.origin=a.origin);a.destination&&(b.destination=a.destination);a.strategy&&(b.strategy=a.strategy);a.city&&(b.city=a.city);a.cityd&&(b.cityd=a.cityd);wx.request({url:"https://restapi.amap.com/v3/direction/transit/integrated",data:b,method:"GET",header:{"content-type":"application/json"},success:function(c){c&&c.data&&c.data.route&&(c=c.data.route,a.success({distance:c.distance||"",taxi_cost:c.taxi_cost|| -"",transits:c.transits}))},fail:function(c){a.fail({errCode:"0",errMsg:c.errMsg||""})}})}; -AMapWX.prototype.getRidingRoute=function(a){var b=Object.assign({},this.requestConfig);a.origin&&(b.origin=a.origin);a.destination&&(b.destination=a.destination);wx.request({url:"https://restapi.amap.com/v3/direction/riding",data:b,method:"GET",header:{"content-type":"application/json"},success:function(c){c&&c.data&&c.data.route&&a.success({paths:c.data.route.paths})},fail:function(c){a.fail({errCode:"0",errMsg:c.errMsg||""})}})};module.exports.AMapWX=AMapWX; \ No newline at end of file diff --git a/utils/qqmap-wx-jssdk.js b/utils/qqmap-wx-jssdk.js new file mode 100644 index 0000000..595b65b --- /dev/null +++ b/utils/qqmap-wx-jssdk.js @@ -0,0 +1,1122 @@ +/** + * 寰俊灏忕▼搴廕avaScriptSDK + * + * @version 1.2 + * @date 2019-03-06 + */ + +var ERROR_CONF = { + KEY_ERR: 311, + KEY_ERR_MSG: 'key鏍煎紡閿欒', + PARAM_ERR: 310, + PARAM_ERR_MSG: '璇锋眰鍙傛暟淇℃伅鏈夎', + SYSTEM_ERR: 600, + SYSTEM_ERR_MSG: '绯荤粺閿欒', + WX_ERR_CODE: 1000, + WX_OK_CODE: 200 +}; +var BASE_URL = 'https://apis.map.qq.com/ws/'; +var URL_SEARCH = BASE_URL + 'place/v1/search'; +var URL_SUGGESTION = BASE_URL + 'place/v1/suggestion'; +var URL_GET_GEOCODER = BASE_URL + 'geocoder/v1/'; +var URL_CITY_LIST = BASE_URL + 'district/v1/list'; +var URL_AREA_LIST = BASE_URL + 'district/v1/getchildren'; +var URL_DISTANCE = BASE_URL + 'distance/v1/'; +var URL_DIRECTION = BASE_URL + 'direction/v1/'; +var MODE = { + driving: 'driving', + transit: 'transit' +}; +var EARTH_RADIUS = 6378136.49; +var Utils = { + /** + * md5鍔犲瘑鏂规硶 + * 鐗堟潈鎵�鏈壜�2011 Sebastian Tschan锛宧ttps锛�//blueimp.net + */ + safeAdd(x, y) { + var lsw = (x & 0xffff) + (y & 0xffff); + var msw = (x >> 16) + (y >> 16) + (lsw >> 16); + return (msw << 16) | (lsw & 0xffff); + }, + bitRotateLeft(num, cnt) { + return (num << cnt) | (num >>> (32 - cnt)); + }, + md5cmn(q, a, b, x, s, t) { + return this.safeAdd(this.bitRotateLeft(this.safeAdd(this.safeAdd(a, q), this.safeAdd(x, t)), s), b); + }, + md5ff(a, b, c, d, x, s, t) { + return this.md5cmn((b & c) | (~b & d), a, b, x, s, t); + }, + md5gg(a, b, c, d, x, s, t) { + return this.md5cmn((b & d) | (c & ~d), a, b, x, s, t); + }, + md5hh(a, b, c, d, x, s, t) { + return this.md5cmn(b ^ c ^ d, a, b, x, s, t); + }, + md5ii(a, b, c, d, x, s, t) { + return this.md5cmn(c ^ (b | ~d), a, b, x, s, t); + }, + binlMD5(x, len) { + /* append padding */ + x[len >> 5] |= 0x80 << (len % 32); + x[((len + 64) >>> 9 << 4) + 14] = len; + + var i; + var olda; + var oldb; + var oldc; + var oldd; + var a = 1732584193; + var b = -271733879; + var c = -1732584194; + var d = 271733878; + + for (i = 0; i < x.length; i += 16) { + olda = a; + oldb = b; + oldc = c; + oldd = d; + + a = this.md5ff(a, b, c, d, x[i], 7, -680876936); + d = this.md5ff(d, a, b, c, x[i + 1], 12, -389564586); + c = this.md5ff(c, d, a, b, x[i + 2], 17, 606105819); + b = this.md5ff(b, c, d, a, x[i + 3], 22, -1044525330); + a = this.md5ff(a, b, c, d, x[i + 4], 7, -176418897); + d = this.md5ff(d, a, b, c, x[i + 5], 12, 1200080426); + c = this.md5ff(c, d, a, b, x[i + 6], 17, -1473231341); + b = this.md5ff(b, c, d, a, x[i + 7], 22, -45705983); + a = this.md5ff(a, b, c, d, x[i + 8], 7, 1770035416); + d = this.md5ff(d, a, b, c, x[i + 9], 12, -1958414417); + c = this.md5ff(c, d, a, b, x[i + 10], 17, -42063); + b = this.md5ff(b, c, d, a, x[i + 11], 22, -1990404162); + a = this.md5ff(a, b, c, d, x[i + 12], 7, 1804603682); + d = this.md5ff(d, a, b, c, x[i + 13], 12, -40341101); + c = this.md5ff(c, d, a, b, x[i + 14], 17, -1502002290); + b = this.md5ff(b, c, d, a, x[i + 15], 22, 1236535329); + + a = this.md5gg(a, b, c, d, x[i + 1], 5, -165796510); + d = this.md5gg(d, a, b, c, x[i + 6], 9, -1069501632); + c = this.md5gg(c, d, a, b, x[i + 11], 14, 643717713); + b = this.md5gg(b, c, d, a, x[i], 20, -373897302); + a = this.md5gg(a, b, c, d, x[i + 5], 5, -701558691); + d = this.md5gg(d, a, b, c, x[i + 10], 9, 38016083); + c = this.md5gg(c, d, a, b, x[i + 15], 14, -660478335); + b = this.md5gg(b, c, d, a, x[i + 4], 20, -405537848); + a = this.md5gg(a, b, c, d, x[i + 9], 5, 568446438); + d = this.md5gg(d, a, b, c, x[i + 14], 9, -1019803690); + c = this.md5gg(c, d, a, b, x[i + 3], 14, -187363961); + b = this.md5gg(b, c, d, a, x[i + 8], 20, 1163531501); + a = this.md5gg(a, b, c, d, x[i + 13], 5, -1444681467); + d = this.md5gg(d, a, b, c, x[i + 2], 9, -51403784); + c = this.md5gg(c, d, a, b, x[i + 7], 14, 1735328473); + b = this.md5gg(b, c, d, a, x[i + 12], 20, -1926607734); + + a = this.md5hh(a, b, c, d, x[i + 5], 4, -378558); + d = this.md5hh(d, a, b, c, x[i + 8], 11, -2022574463); + c = this.md5hh(c, d, a, b, x[i + 11], 16, 1839030562); + b = this.md5hh(b, c, d, a, x[i + 14], 23, -35309556); + a = this.md5hh(a, b, c, d, x[i + 1], 4, -1530992060); + d = this.md5hh(d, a, b, c, x[i + 4], 11, 1272893353); + c = this.md5hh(c, d, a, b, x[i + 7], 16, -155497632); + b = this.md5hh(b, c, d, a, x[i + 10], 23, -1094730640); + a = this.md5hh(a, b, c, d, x[i + 13], 4, 681279174); + d = this.md5hh(d, a, b, c, x[i], 11, -358537222); + c = this.md5hh(c, d, a, b, x[i + 3], 16, -722521979); + b = this.md5hh(b, c, d, a, x[i + 6], 23, 76029189); + a = this.md5hh(a, b, c, d, x[i + 9], 4, -640364487); + d = this.md5hh(d, a, b, c, x[i + 12], 11, -421815835); + c = this.md5hh(c, d, a, b, x[i + 15], 16, 530742520); + b = this.md5hh(b, c, d, a, x[i + 2], 23, -995338651); + + a = this.md5ii(a, b, c, d, x[i], 6, -198630844); + d = this.md5ii(d, a, b, c, x[i + 7], 10, 1126891415); + c = this.md5ii(c, d, a, b, x[i + 14], 15, -1416354905); + b = this.md5ii(b, c, d, a, x[i + 5], 21, -57434055); + a = this.md5ii(a, b, c, d, x[i + 12], 6, 1700485571); + d = this.md5ii(d, a, b, c, x[i + 3], 10, -1894986606); + c = this.md5ii(c, d, a, b, x[i + 10], 15, -1051523); + b = this.md5ii(b, c, d, a, x[i + 1], 21, -2054922799); + a = this.md5ii(a, b, c, d, x[i + 8], 6, 1873313359); + d = this.md5ii(d, a, b, c, x[i + 15], 10, -30611744); + c = this.md5ii(c, d, a, b, x[i + 6], 15, -1560198380); + b = this.md5ii(b, c, d, a, x[i + 13], 21, 1309151649); + a = this.md5ii(a, b, c, d, x[i + 4], 6, -145523070); + d = this.md5ii(d, a, b, c, x[i + 11], 10, -1120210379); + c = this.md5ii(c, d, a, b, x[i + 2], 15, 718787259); + b = this.md5ii(b, c, d, a, x[i + 9], 21, -343485551); + + a = this.safeAdd(a, olda); + b = this.safeAdd(b, oldb); + c = this.safeAdd(c, oldc); + d = this.safeAdd(d, oldd); + } + return [a, b, c, d]; + }, + binl2rstr(input) { + var i; + var output = ''; + var length32 = input.length * 32; + for (i = 0; i < length32; i += 8) { + output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xff); + } + return output; + }, + rstr2binl(input) { + var i; + var output = []; + output[(input.length >> 2) - 1] = undefined; + for (i = 0; i < output.length; i += 1) { + output[i] = 0; + } + var length8 = input.length * 8; + for (i = 0; i < length8; i += 8) { + output[i >> 5] |= (input.charCodeAt(i / 8) & 0xff) << (i % 32); + } + return output; + }, + rstrMD5(s) { + return this.binl2rstr(this.binlMD5(this.rstr2binl(s), s.length * 8)); + }, + rstrHMACMD5(key, data) { + var i; + var bkey = this.rstr2binl(key); + var ipad = []; + var opad = []; + var hash; + ipad[15] = opad[15] = undefined; + if (bkey.length > 16) { + bkey = this.binlMD5(bkey, key.length * 8); + } + for (i = 0; i < 16; i += 1) { + ipad[i] = bkey[i] ^ 0x36363636; + opad[i] = bkey[i] ^ 0x5c5c5c5c; + } + hash = this.binlMD5(ipad.concat(this.rstr2binl(data)), 512 + data.length * 8); + return this.binl2rstr(this.binlMD5(opad.concat(hash), 512 + 128)); + }, + rstr2hex(input) { + var hexTab = '0123456789abcdef'; + var output = ''; + var x; + var i; + for (i = 0; i < input.length; i += 1) { + x = input.charCodeAt(i); + output += hexTab.charAt((x >>> 4) & 0x0f) + hexTab.charAt(x & 0x0f); + } + return output; + }, + str2rstrUTF8(input) { + return unescape(encodeURIComponent(input)); + }, + rawMD5(s) { + return this.rstrMD5(this.str2rstrUTF8(s)); + }, + hexMD5(s) { + return this.rstr2hex(this.rawMD5(s)); + }, + rawHMACMD5(k, d) { + return this.rstrHMACMD5(this.str2rstrUTF8(k), str2rstrUTF8(d)); + }, + hexHMACMD5(k, d) { + return this.rstr2hex(this.rawHMACMD5(k, d)); + }, + + md5(string, key, raw) { + if (!key) { + if (!raw) { + return this.hexMD5(string); + } + return this.rawMD5(string); + } + if (!raw) { + return this.hexHMACMD5(key, string); + } + return this.rawHMACMD5(key, string); + }, + /** + * 寰楀埌md5鍔犲瘑鍚庣殑sig鍙傛暟 + * @param {Object} requestParam 鎺ュ彛鍙傛暟 + * @param {String} sk绛惧悕瀛楃涓� + * @param {String} featrue 鏂规硶鍚� + * @return 杩斿洖鍔犲瘑鍚庣殑sig鍙傛暟 + */ + getSig(requestParam, sk, feature, mode) { + var sig = null; + var requestArr = []; + Object.keys(requestParam).sort().forEach(function(key){ + requestArr.push(key + '=' + requestParam[key]); + }); + if (feature == 'search') { + sig = '/ws/place/v1/search?' + requestArr.join('&') + sk; + } + if (feature == 'suggest') { + sig = '/ws/place/v1/suggestion?' + requestArr.join('&') + sk; + } + if (feature == 'reverseGeocoder') { + sig = '/ws/geocoder/v1/?' + requestArr.join('&') + sk; + } + if (feature == 'geocoder') { + sig = '/ws/geocoder/v1/?' + requestArr.join('&') + sk; + } + if (feature == 'getCityList') { + sig = '/ws/district/v1/list?' + requestArr.join('&') + sk; + } + if (feature == 'getDistrictByCityId') { + sig = '/ws/district/v1/getchildren?' + requestArr.join('&') + sk; + } + if (feature == 'calculateDistance') { + sig = '/ws/distance/v1/?' + requestArr.join('&') + sk; + } + if (feature == 'direction') { + sig = '/ws/direction/v1/' + mode + '?' + requestArr.join('&') + sk; + } + sig = this.md5(sig); + return sig; + }, + /** + * 寰楀埌缁堢偣query瀛楃涓� + * @param {Array|String} 妫�绱㈡暟鎹� + */ + location2query(data) { + if (typeof data == 'string') { + return data; + } + var query = ''; + for (var i = 0; i < data.length; i++) { + var d = data[i]; + if (!!query) { + query += ';'; + } + if (d.location) { + query = query + d.location.lat + ',' + d.location.lng; + } + if (d.latitude && d.longitude) { + query = query + d.latitude + ',' + d.longitude; + } + } + return query; + }, + + /** + * 璁$畻瑙掑害 + */ + rad(d) { + return d * Math.PI / 180.0; + }, + /** + * 澶勭悊缁堢偣location鏁扮粍 + * @return 杩斿洖缁堢偣鏁扮粍 + */ + getEndLocation(location){ + var to = location.split(';'); + var endLocation = []; + for (var i = 0; i < to.length; i++) { + endLocation.push({ + lat: parseFloat(to[i].split(',')[0]), + lng: parseFloat(to[i].split(',')[1]) + }) + } + return endLocation; + }, + + /** + * 璁$畻涓ょ偣闂寸洿绾胯窛绂� + * @param a 琛ㄧず绾害宸� + * @param b 琛ㄧず缁忓害宸� + * @return 杩斿洖鐨勬槸璺濈锛屽崟浣峬 + */ + getDistance(latFrom, lngFrom, latTo, lngTo) { + var radLatFrom = this.rad(latFrom); + var radLatTo = this.rad(latTo); + var a = radLatFrom - radLatTo; + var b = this.rad(lngFrom) - this.rad(lngTo); + var distance = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLatFrom) * Math.cos(radLatTo) * Math.pow(Math.sin(b / 2), 2))); + distance = distance * EARTH_RADIUS; + distance = Math.round(distance * 10000) / 10000; + return parseFloat(distance.toFixed(0)); + }, + /** + * 浣跨敤寰俊鎺ュ彛杩涜瀹氫綅 + */ + getWXLocation(success, fail, complete) { + wx.getLocation({ + type: 'gcj02', + success: success, + fail: fail, + complete: complete + }); + }, + + /** + * 鑾峰彇location鍙傛暟 + */ + getLocationParam(location) { + if (typeof location == 'string') { + var locationArr = location.split(','); + if (locationArr.length === 2) { + location = { + latitude: location.split(',')[0], + longitude: location.split(',')[1] + }; + } else { + location = {}; + } + } + return location; + }, + + /** + * 鍥炶皟鍑芥暟榛樿澶勭悊 + */ + polyfillParam(param) { + param.success = param.success || function () { }; + param.fail = param.fail || function () { }; + param.complete = param.complete || function () { }; + }, + + /** + * 楠岃瘉param瀵瑰簲鐨刱ey鍊兼槸鍚︿负绌� + * + * @param {Object} param 鎺ュ彛鍙傛暟 + * @param {String} key 瀵瑰簲鍙傛暟鐨刱ey + */ + checkParamKeyEmpty(param, key) { + if (!param[key]) { + var errconf = this.buildErrorConfig(ERROR_CONF.PARAM_ERR, ERROR_CONF.PARAM_ERR_MSG + key +'鍙傛暟鏍煎紡鏈夎'); + param.fail(errconf); + param.complete(errconf); + return true; + } + return false; + }, + + /** + * 楠岃瘉鍙傛暟涓槸鍚﹀瓨鍦ㄦ绱㈣瘝keyword + * + * @param {Object} param 鎺ュ彛鍙傛暟 + */ + checkKeyword(param){ + return !this.checkParamKeyEmpty(param, 'keyword'); + }, + + /** + * 楠岃瘉location鍊� + * + * @param {Object} param 鎺ュ彛鍙傛暟 + */ + checkLocation(param) { + var location = this.getLocationParam(param.location); + if (!location || !location.latitude || !location.longitude) { + var errconf = this.buildErrorConfig(ERROR_CONF.PARAM_ERR, ERROR_CONF.PARAM_ERR_MSG + ' location鍙傛暟鏍煎紡鏈夎'); + param.fail(errconf); + param.complete(errconf); + return false; + } + return true; + }, + + /** + * 鏋勯�犻敊璇暟鎹粨鏋� + * @param {Number} errCode 閿欒鐮� + * @param {Number} errMsg 閿欒鎻忚堪 + */ + buildErrorConfig(errCode, errMsg) { + return { + status: errCode, + message: errMsg + }; + }, + + /** + * + * 鏁版嵁澶勭悊鍑芥暟 + * 鏍规嵁浼犲叆鍙傛暟涓嶅悓澶勭悊涓嶅悓鏁版嵁 + * @param {String} feature 鍔熻兘鍚嶇О + * search 鍦扮偣鎼滅储 + * suggest鍏抽敭璇嶆彁绀� + * reverseGeocoder閫嗗湴鍧�瑙f瀽 + * geocoder鍦板潃瑙f瀽 + * getCityList鑾峰彇鍩庡競鍒楄〃锛氱埗闆� + * getDistrictByCityId鑾峰彇鍖哄幙鍒楄〃锛氬瓙闆� + * calculateDistance璺濈璁$畻 + * @param {Object} param 鎺ュ彛鍙傛暟 + * @param {Object} data 鏁版嵁 + */ + handleData(param,data,feature){ + if (feature == 'search') { + var searchResult = data.data; + var searchSimplify = []; + for (var i = 0; i < searchResult.length; i++) { + searchSimplify.push({ + id: searchResult[i].id || null, + title: searchResult[i].title || null, + latitude: searchResult[i].location && searchResult[i].location.lat || null, + longitude: searchResult[i].location && searchResult[i].location.lng || null, + address: searchResult[i].address || null, + category: searchResult[i].category || null, + tel: searchResult[i].tel || null, + adcode: searchResult[i].ad_info && searchResult[i].ad_info.adcode || null, + city: searchResult[i].ad_info && searchResult[i].ad_info.city || null, + district: searchResult[i].ad_info && searchResult[i].ad_info.district || null, + province: searchResult[i].ad_info && searchResult[i].ad_info.province || null + }) + } + param.success(data, { + searchResult: searchResult, + searchSimplify: searchSimplify + }) + } else if (feature == 'suggest') { + var suggestResult = data.data; + var suggestSimplify = []; + for (var i = 0; i < suggestResult.length; i++) { + suggestSimplify.push({ + adcode: suggestResult[i].adcode || null, + address: suggestResult[i].address || null, + category: suggestResult[i].category || null, + city: suggestResult[i].city || null, + district: suggestResult[i].district || null, + id: suggestResult[i].id || null, + latitude: suggestResult[i].location && suggestResult[i].location.lat || null, + longitude: suggestResult[i].location && suggestResult[i].location.lng || null, + province: suggestResult[i].province || null, + title: suggestResult[i].title || null, + type: suggestResult[i].type || null + }) + } + param.success(data, { + suggestResult: suggestResult, + suggestSimplify: suggestSimplify + }) + } else if (feature == 'reverseGeocoder') { + var reverseGeocoderResult = data.result; + var reverseGeocoderSimplify = { + address: reverseGeocoderResult.address || null, + latitude: reverseGeocoderResult.location && reverseGeocoderResult.location.lat || null, + longitude: reverseGeocoderResult.location && reverseGeocoderResult.location.lng || null, + adcode: reverseGeocoderResult.ad_info && reverseGeocoderResult.ad_info.adcode || null, + city: reverseGeocoderResult.address_component && reverseGeocoderResult.address_component.city || null, + district: reverseGeocoderResult.address_component && reverseGeocoderResult.address_component.district || null, + nation: reverseGeocoderResult.address_component && reverseGeocoderResult.address_component.nation || null, + province: reverseGeocoderResult.address_component && reverseGeocoderResult.address_component.province || null, + street: reverseGeocoderResult.address_component && reverseGeocoderResult.address_component.street || null, + street_number: reverseGeocoderResult.address_component && reverseGeocoderResult.address_component.street_number || null, + recommend: reverseGeocoderResult.formatted_addresses && reverseGeocoderResult.formatted_addresses.recommend || null, + rough: reverseGeocoderResult.formatted_addresses && reverseGeocoderResult.formatted_addresses.rough || null + }; + if (reverseGeocoderResult.pois) {//鍒ゆ柇鏄惁杩斿洖鍛ㄨ竟poi + var pois = reverseGeocoderResult.pois; + var poisSimplify = []; + for (var i = 0;i < pois.length;i++) { + poisSimplify.push({ + id: pois[i].id || null, + title: pois[i].title || null, + latitude: pois[i].location && pois[i].location.lat || null, + longitude: pois[i].location && pois[i].location.lng || null, + address: pois[i].address || null, + category: pois[i].category || null, + adcode: pois[i].ad_info && pois[i].ad_info.adcode || null, + city: pois[i].ad_info && pois[i].ad_info.city || null, + district: pois[i].ad_info && pois[i].ad_info.district || null, + province: pois[i].ad_info && pois[i].ad_info.province || null + }) + } + param.success(data,{ + reverseGeocoderResult: reverseGeocoderResult, + reverseGeocoderSimplify: reverseGeocoderSimplify, + pois: pois, + poisSimplify: poisSimplify + }) + } else { + param.success(data, { + reverseGeocoderResult: reverseGeocoderResult, + reverseGeocoderSimplify: reverseGeocoderSimplify + }) + } + } else if (feature == 'geocoder') { + var geocoderResult = data.result; + var geocoderSimplify = { + title: geocoderResult.title || null, + latitude: geocoderResult.location && geocoderResult.location.lat || null, + longitude: geocoderResult.location && geocoderResult.location.lng || null, + adcode: geocoderResult.ad_info && geocoderResult.ad_info.adcode || null, + province: geocoderResult.address_components && geocoderResult.address_components.province || null, + city: geocoderResult.address_components && geocoderResult.address_components.city || null, + district: geocoderResult.address_components && geocoderResult.address_components.district || null, + street: geocoderResult.address_components && geocoderResult.address_components.street || null, + street_number: geocoderResult.address_components && geocoderResult.address_components.street_number || null, + level: geocoderResult.level || null + }; + param.success(data,{ + geocoderResult: geocoderResult, + geocoderSimplify: geocoderSimplify + }); + } else if (feature == 'getCityList') { + var provinceResult = data.result[0]; + var cityResult = data.result[1]; + var districtResult = data.result[2]; + param.success(data,{ + provinceResult: provinceResult, + cityResult: cityResult, + districtResult: districtResult + }); + } else if (feature == 'getDistrictByCityId') { + var districtByCity = data.result[0]; + param.success(data, districtByCity); + } else if (feature == 'calculateDistance') { + var calculateDistanceResult = data.result.elements; + var distance = []; + for (var i = 0; i < calculateDistanceResult.length; i++){ + distance.push(calculateDistanceResult[i].distance); + } + param.success(data, { + calculateDistanceResult: calculateDistanceResult, + distance: distance + }); + } else if (feature == 'direction') { + var direction = data.result.routes; + param.success(data,direction); + } else { + param.success(data); + } + }, + + /** + * 鏋勯�犲井淇¤姹傚弬鏁帮紝鍏叡灞炴�у鐞� + * + * @param {Object} param 鎺ュ彛鍙傛暟 + * @param {Object} param 閰嶇疆椤� + * @param {String} feature 鏂规硶鍚� + */ + buildWxRequestConfig(param, options, feature) { + var that = this; + options.header = { "content-type": "application/json" }; + options.method = 'GET'; + options.success = function (res) { + var data = res.data; + if (data.status === 0) { + that.handleData(param, data, feature); + } else { + param.fail(data); + } + }; + options.fail = function (res) { + res.statusCode = ERROR_CONF.WX_ERR_CODE; + param.fail(that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, res.errMsg)); + }; + options.complete = function (res) { + var statusCode = +res.statusCode; + switch(statusCode) { + case ERROR_CONF.WX_ERR_CODE: { + param.complete(that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, res.errMsg)); + break; + } + case ERROR_CONF.WX_OK_CODE: { + var data = res.data; + if (data.status === 0) { + param.complete(data); + } else { + param.complete(that.buildErrorConfig(data.status, data.message)); + } + break; + } + default:{ + param.complete(that.buildErrorConfig(ERROR_CONF.SYSTEM_ERR, ERROR_CONF.SYSTEM_ERR_MSG)); + } + + } + }; + return options; + }, + + /** + * 澶勭悊鐢ㄦ埛鍙傛暟鏄惁浼犲叆鍧愭爣杩涜涓嶅悓鐨勫鐞� + */ + locationProcess(param, locationsuccess, locationfail, locationcomplete) { + var that = this; + locationfail = locationfail || function (res) { + res.statusCode = ERROR_CONF.WX_ERR_CODE; + param.fail(that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, res.errMsg)); + }; + locationcomplete = locationcomplete || function (res) { + if (res.statusCode == ERROR_CONF.WX_ERR_CODE) { + param.complete(that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, res.errMsg)); + } + }; + if (!param.location) { + that.getWXLocation(locationsuccess, locationfail, locationcomplete); + } else if (that.checkLocation(param)) { + var location = Utils.getLocationParam(param.location); + locationsuccess(location); + } + } +}; + + +class QQMapWX { + + /** + * 鏋勯�犲嚱鏁� + * + * @param {Object} options 鎺ュ彛鍙傛暟,key 涓哄繀閫夊弬鏁� + */ + constructor(options) { + if (!options.key) { + throw Error('key鍊间笉鑳戒负绌�'); + } + this.key = options.key; + }; + + /** + * POI鍛ㄨ竟妫�绱� + * + * @param {Object} options 鎺ュ彛鍙傛暟瀵硅薄 + * + * 鍙傛暟瀵硅薄缁撴瀯鍙互鍙傝�� + * @see http://lbs.qq.com/webservice_v1/guide-search.html + */ + search(options) { + var that = this; + options = options || {}; + + Utils.polyfillParam(options); + + if (!Utils.checkKeyword(options)) { + return; + } + + var requestParam = { + keyword: options.keyword, + orderby: options.orderby || '_distance', + page_size: options.page_size || 10, + page_index: options.page_index || 1, + output: 'json', + key: that.key + }; + + if (options.address_format) { + requestParam.address_format = options.address_format; + } + + if (options.filter) { + requestParam.filter = options.filter; + } + + var distance = options.distance || "1000"; + var auto_extend = options.auto_extend || 1; + var region = null; + var rectangle = null; + + //鍒ゆ柇鍩庡競闄愬畾鍙傛暟 + if (options.region) { + region = options.region; + } + + //鐭╁舰闄愬畾鍧愭爣(鏆傛椂鍙敮鎸佸瓧绗︿覆鏍煎紡) + if (options.rectangle) { + rectangle = options.rectangle; + } + + var locationsuccess = function (result) { + if (region && !rectangle) { + //鍩庡競闄愬畾鍙傛暟鎷兼帴 + requestParam.boundary = "region(" + region + "," + auto_extend + "," + result.latitude + "," + result.longitude + ")"; + if (options.sig) { + requestParam.sig = Utils.getSig(requestParam, options.sig, 'search'); + } + } else if (rectangle && !region) { + //鐭╁舰鎼滅储 + requestParam.boundary = "rectangle(" + rectangle + ")"; + if (options.sig) { + requestParam.sig = Utils.getSig(requestParam, options.sig, 'search'); + } + } else { + requestParam.boundary = "nearby(" + result.latitude + "," + result.longitude + "," + distance + "," + auto_extend + ")"; + if (options.sig) { + requestParam.sig = Utils.getSig(requestParam, options.sig, 'search'); + } + } + wx.request(Utils.buildWxRequestConfig(options, { + url: URL_SEARCH, + data: requestParam + }, 'search')); + }; + Utils.locationProcess(options, locationsuccess); + }; + + /** + * sug妯$硦妫�绱� + * + * @param {Object} options 鎺ュ彛鍙傛暟瀵硅薄 + * + * 鍙傛暟瀵硅薄缁撴瀯鍙互鍙傝�� + * http://lbs.qq.com/webservice_v1/guide-suggestion.html + */ + getSuggestion(options) { + var that = this; + options = options || {}; + Utils.polyfillParam(options); + + if (!Utils.checkKeyword(options)) { + return; + } + + var requestParam = { + keyword: options.keyword, + region: options.region || '鍏ㄥ浗', + region_fix: options.region_fix || 0, + policy: options.policy || 0, + page_size: options.page_size || 10,//鎺у埗鏄剧ず鏉℃暟 + page_index: options.page_index || 1,//鎺у埗椤垫暟 + get_subpois : options.get_subpois || 0,//杩斿洖瀛愬湴鐐� + output: 'json', + key: that.key + }; + //闀垮湴鍧� + if (options.address_format) { + requestParam.address_format = options.address_format; + } + //杩囨护 + if (options.filter) { + requestParam.filter = options.filter; + } + //鎺掑簭 + if (options.location) { + var locationsuccess = function (result) { + requestParam.location = result.latitude + ',' + result.longitude; + if (options.sig) { + requestParam.sig = Utils.getSig(requestParam, options.sig, 'suggest'); + } + wx.request(Utils.buildWxRequestConfig(options, { + url: URL_SUGGESTION, + data: requestParam + }, "suggest")); + }; + Utils.locationProcess(options, locationsuccess); + } else { + if (options.sig) { + requestParam.sig = Utils.getSig(requestParam, options.sig, 'suggest'); + } + wx.request(Utils.buildWxRequestConfig(options, { + url: URL_SUGGESTION, + data: requestParam + }, "suggest")); + } + }; + + /** + * 閫嗗湴鍧�瑙f瀽 + * + * @param {Object} options 鎺ュ彛鍙傛暟瀵硅薄 + * + * 璇锋眰鍙傛暟缁撴瀯鍙互鍙傝�� + * http://lbs.qq.com/webservice_v1/guide-gcoder.html + */ + reverseGeocoder(options) { + var that = this; + options = options || {}; + Utils.polyfillParam(options); + var requestParam = { + coord_type: options.coord_type || 5, + get_poi: options.get_poi || 0, + output: 'json', + key: that.key + }; + if (options.poi_options) { + requestParam.poi_options = options.poi_options + } + + var locationsuccess = function (result) { + requestParam.location = result.latitude + ',' + result.longitude; + if (options.sig) { + requestParam.sig = Utils.getSig(requestParam, options.sig, 'reverseGeocoder'); + } + wx.request(Utils.buildWxRequestConfig(options, { + url: URL_GET_GEOCODER, + data: requestParam + }, 'reverseGeocoder')); + }; + Utils.locationProcess(options, locationsuccess); + }; + + /** + * 鍦板潃瑙f瀽 + * + * @param {Object} options 鎺ュ彛鍙傛暟瀵硅薄 + * + * 璇锋眰鍙傛暟缁撴瀯鍙互鍙傝�� + * http://lbs.qq.com/webservice_v1/guide-geocoder.html + */ + geocoder(options) { + var that = this; + options = options || {}; + Utils.polyfillParam(options); + + if (Utils.checkParamKeyEmpty(options, 'address')) { + return; + } + + var requestParam = { + address: options.address, + output: 'json', + key: that.key + }; + + //鍩庡競闄愬畾 + if (options.region) { + requestParam.region = options.region; + } + + if (options.sig) { + requestParam.sig = Utils.getSig(requestParam, options.sig, 'geocoder'); + } + + wx.request(Utils.buildWxRequestConfig(options, { + url: URL_GET_GEOCODER, + data: requestParam + },'geocoder')); + }; + + + /** + * 鑾峰彇鍩庡競鍒楄〃 + * + * @param {Object} options 鎺ュ彛鍙傛暟瀵硅薄 + * + * 璇锋眰鍙傛暟缁撴瀯鍙互鍙傝�� + * http://lbs.qq.com/webservice_v1/guide-region.html + */ + getCityList(options) { + var that = this; + options = options || {}; + Utils.polyfillParam(options); + var requestParam = { + output: 'json', + key: that.key + }; + + if (options.sig) { + requestParam.sig = Utils.getSig(requestParam, options.sig, 'getCityList'); + } + + wx.request(Utils.buildWxRequestConfig(options, { + url: URL_CITY_LIST, + data: requestParam + },'getCityList')); + }; + + /** + * 鑾峰彇瀵瑰簲鍩庡競ID鐨勫尯鍘垮垪琛� + * + * @param {Object} options 鎺ュ彛鍙傛暟瀵硅薄 + * + * 璇锋眰鍙傛暟缁撴瀯鍙互鍙傝�� + * http://lbs.qq.com/webservice_v1/guide-region.html + */ + getDistrictByCityId(options) { + var that = this; + options = options || {}; + Utils.polyfillParam(options); + + if (Utils.checkParamKeyEmpty(options, 'id')) { + return; + } + + var requestParam = { + id: options.id || '', + output: 'json', + key: that.key + }; + + if (options.sig) { + requestParam.sig = Utils.getSig(requestParam, options.sig, 'getDistrictByCityId'); + } + + wx.request(Utils.buildWxRequestConfig(options, { + url: URL_AREA_LIST, + data: requestParam + },'getDistrictByCityId')); + }; + + /** + * 鐢ㄤ簬鍗曡捣鐐瑰埌澶氱粓鐐圭殑璺嚎璺濈(闈炵洿绾胯窛绂�)璁$畻锛� + * 鏀寔涓ょ璺濈璁$畻鏂瑰紡锛氭琛屽拰椹捐溅銆� + * 璧风偣鍒扮粓鐐规渶澶ч檺鍒剁洿绾胯窛绂�10鍏噷銆� + * + * 鏂板鐩寸嚎璺濈璁$畻銆� + * + * @param {Object} options 鎺ュ彛鍙傛暟瀵硅薄 + * + * 璇锋眰鍙傛暟缁撴瀯鍙互鍙傝�� + * http://lbs.qq.com/webservice_v1/guide-distance.html + */ + calculateDistance(options) { + var that = this; + options = options || {}; + Utils.polyfillParam(options); + + if (Utils.checkParamKeyEmpty(options, 'to')) { + return; + } + + var requestParam = { + mode: options.mode || 'walking', + to: Utils.location2query(options.to), + output: 'json', + key: that.key + }; + + if (options.from) { + options.location = options.from; + } + + //璁$畻鐩寸嚎璺濈 + if(requestParam.mode == 'straight'){ + var locationsuccess = function (result) { + var locationTo = Utils.getEndLocation(requestParam.to);//澶勭悊缁堢偣鍧愭爣 + var data = { + message:"query ok", + result:{ + elements:[] + }, + status:0 + }; + for (var i = 0; i < locationTo.length; i++) { + data.result.elements.push({//灏嗗潗鏍囧瓨鍏� + distance: Utils.getDistance(result.latitude, result.longitude, locationTo[i].lat, locationTo[i].lng), + duration:0, + from:{ + lat: result.latitude, + lng:result.longitude + }, + to:{ + lat: locationTo[i].lat, + lng: locationTo[i].lng + } + }); + } + var calculateResult = data.result.elements; + var distanceResult = []; + for (var i = 0; i < calculateResult.length; i++) { + distanceResult.push(calculateResult[i].distance); + } + return options.success(data,{ + calculateResult: calculateResult, + distanceResult: distanceResult + }); + }; + + Utils.locationProcess(options, locationsuccess); + } else { + var locationsuccess = function (result) { + requestParam.from = result.latitude + ',' + result.longitude; + if (options.sig) { + requestParam.sig = Utils.getSig(requestParam, options.sig, 'calculateDistance'); + } + wx.request(Utils.buildWxRequestConfig(options, { + url: URL_DISTANCE, + data: requestParam + },'calculateDistance')); + }; + + Utils.locationProcess(options, locationsuccess); + } + }; + + /** + * 璺嚎瑙勫垝锛� + * + * @param {Object} options 鎺ュ彛鍙傛暟瀵硅薄 + * + * 璇锋眰鍙傛暟缁撴瀯鍙互鍙傝�� + * https://lbs.qq.com/webservice_v1/guide-road.html + */ + direction(options) { + var that = this; + options = options || {}; + Utils.polyfillParam(options); + + if (Utils.checkParamKeyEmpty(options, 'to')) { + return; + } + + var requestParam = { + output: 'json', + key: that.key + }; + + //to鏍煎紡澶勭悊 + if (typeof options.to == 'string') { + requestParam.to = options.to; + } else { + requestParam.to = options.to.latitude + ',' + options.to.longitude; + } + //鍒濆鍖栧眬閮ㄨ姹傚煙鍚� + var SET_URL_DIRECTION = null; + //璁剧疆榛樿mode灞炴�� + options.mode = options.mode || MODE.driving; + + //璁剧疆璇锋眰鍩熷悕 + SET_URL_DIRECTION = URL_DIRECTION + options.mode; + + if (options.from) { + options.location = options.from; + } + + if (options.mode == MODE.driving) { + if (options.from_poi) { + requestParam.from_poi = options.from_poi; + } + if (options.heading) { + requestParam.heading = options.heading; + } + if (options.speed) { + requestParam.speed = options.speed; + } + if (options.accuracy) { + requestParam.accuracy = options.accuracy; + } + if (options.road_type) { + requestParam.road_type = options.road_type; + } + if (options.to_poi) { + requestParam.to_poi = options.to_poi; + } + if (options.from_track) { + requestParam.from_track = options.from_track; + } + if (options.waypoints) { + requestParam.waypoints = options.waypoints; + } + if (options.policy) { + requestParam.policy = options.policy; + } + if (options.plate_number) { + requestParam.plate_number = options.plate_number; + } + } + + if (options.mode == MODE.transit) { + if (options.departure_time) { + requestParam.departure_time = options.departure_time; + } + if (options.policy) { + requestParam.policy = options.policy; + } + } + + var locationsuccess = function (result) { + requestParam.from = result.latitude + ',' + result.longitude; + if (options.sig) { + requestParam.sig = Utils.getSig(requestParam, options.sig, 'direction',options.mode); + } + wx.request(Utils.buildWxRequestConfig(options, { + url: SET_URL_DIRECTION, + data: requestParam + }, 'direction')); + }; + + Utils.locationProcess(options, locationsuccess); + } +}; + +module.exports = QQMapWX; \ No newline at end of file -- Gitblit v1.9.1