deliverDialo.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <template>
  2. <div id="deliverDialo">
  3. <div class="deliverDialogBox">
  4. <div class="top">
  5. <div class="address CityTapBox">
  6. <img
  7. src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images%2FtaskPackage%2Ffontclass-dizhi%402x.png"
  8. alt=""
  9. />
  10. <div>
  11. {{ city_name }}
  12. <i class="el-icon-arrow-down"></i>
  13. </div>
  14. <el-cascader
  15. class="cascader"
  16. ref="refSubCat"
  17. v-model="district_select"
  18. :options="district"
  19. :props="props"
  20. @change="handleChange"
  21. ></el-cascader>
  22. </div>
  23. <div class="deleverAndAdress">
  24. <el-select v-model="optionsSelectValue" placeholder="请选择" @change="selectChange">
  25. <el-option
  26. v-for="item in optionsSelect"
  27. :key="item.value"
  28. :label="item.label"
  29. :value="item.value"
  30. >
  31. </el-option>
  32. </el-select>
  33. </div>
  34. <div class="inp">
  35. <el-input
  36. v-if="optionsSelectValue == 1"
  37. v-model="deliverDialogInput"
  38. placeholder="搜索自提点a名称"
  39. ></el-input>
  40. <el-input
  41. v-if="optionsSelectValue == 2"
  42. id="suggestId"
  43. v-model="deliverDialogInput"
  44. placeholder="请输入详细的地点"
  45. @focus="focusInp"
  46. ></el-input>
  47. </div>
  48. <div class="searchBtn" @click="search">搜索</div>
  49. </div>
  50. <div class="contenBox">
  51. <div class="list" v-for="(item, index) in info" :key="index" @click="tapChild(item.id)">
  52. <div class="top">
  53. <div class="name">{{ item.deliver_name }}</div>
  54. <div class="btn" @click.stop="checkMore(index)">
  55. {{ !item.close ? "查看" : "收起" }}
  56. <i class="el-icon-arrow-down"></i>
  57. </div>
  58. </div>
  59. <div class="adddress">{{ item.full_address }} 562号</div>
  60. <div class="distance" v-if="item.distance">{{ item.distance }}{{ item.unit }}</div>
  61. <div class="timeContact">
  62. <div class="time">
  63. 营业时间:{{ item.business_hours_start }}-{{
  64. item.business_hours_end
  65. }}
  66. </div>
  67. <div class="phone" v-if="item.close">
  68. 联系电话:{{ item.deliver_mobile }}
  69. </div>
  70. </div>
  71. <div class="thumbBox" v-if="item.close && item.thumb.length > 0">
  72. <div class="txt">图片</div>
  73. <div class="thumbLis">
  74. <template v-for="(items, index) in item.thumb">
  75. <el-image
  76. :key="index"
  77. style="width: 70px; height: 70px"
  78. :src="items"
  79. :preview-src-list="setSrcList(items)"
  80. >
  81. </el-image>
  82. </template>
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. <pagination
  88. v-show="total"
  89. :total="total"
  90. :pageSize="per_page"
  91. @pagination="monitorPage"
  92. :page="page"
  93. />
  94. </div>
  95. </div>
  96. </template>
  97. <script>
  98. import pagination from "~/components/default/pagination";
  99. export default {
  100. props: ["deliverDialogVisible", "city", "pointInfo", "goods", "district"],
  101. data() {
  102. return {
  103. optionsSelect: [
  104. {
  105. value: "1",
  106. label: "自提点",
  107. },
  108. {
  109. value: "2",
  110. label: "地址",
  111. },
  112. ],
  113. optionsSelectValue: "1",
  114. deliverDialogInput: "",
  115. goodsInfo: "",
  116. deliverName: "",
  117. info: "",
  118. srcList: [],
  119. props: {
  120. value: "v",
  121. children: "c",
  122. label: "n",
  123. },
  124. district_select: [],
  125. city_name:'',
  126. point:'',
  127. per_page: 15,
  128. total: 0,
  129. page: 1,
  130. };
  131. },
  132. components: { pagination },
  133. watch: {
  134. deliverDialogVisible: function (nval, oval) {
  135. console.log(nval,oval, "dddddd");
  136. if (nval) {
  137. this.city_name = this.city;
  138. this.point = this.pointInfo;
  139. this.getList(
  140. this.city_name,
  141. this.point.lat,
  142. this.point.lng,
  143. this.deliverDialogInput
  144. );
  145. }else{
  146. this.city_name = this.city;
  147. this.point = this.pointInfo;
  148. this.optionsSelectValue = "1";
  149. this.deliverDialogInput = ''
  150. }
  151. },
  152. },
  153. mounted() {
  154. this.city_name = this.city;
  155. this.point = this.pointInfo;
  156. this.getList(
  157. this.city_name,
  158. this.point.lat,
  159. this.point.lng,
  160. this.deliverDialogInput
  161. );
  162. },
  163. methods: {
  164. tapChild(_id){
  165. // plugin.package-deliver.frontend.decorate-deliver.getNowPackageDeliver
  166. let _url = "plugin.package-deliver.frontend.decorate-deliver.getNowPackageDeliver";
  167. if (!_id) {
  168. console.log("自提点id不能为空!");
  169. return;
  170. }
  171. this.fun.$get(_url, {deliver_id: _id}, ".").then(
  172. (response) => {
  173. if (response.result === 1) {
  174. this.$emit('childDeliver',response.data)
  175. } else {
  176. this.$message.error(response.msg);
  177. }
  178. },
  179. function (response) {
  180. console.log(response);
  181. }
  182. );
  183. },
  184. selectChange(){
  185. this.deliverDialogInput = ''
  186. },
  187. handleChange() {
  188. if (this.$refs["refSubCat"].getCheckedNodes()[0].parent) {
  189. if (this.$refs["refSubCat"].getCheckedNodes()[0].parent.parent) {
  190. let district =
  191. this.$refs["refSubCat"].getCheckedNodes()[0].label;
  192. let city =
  193. this.$refs["refSubCat"].getCheckedNodes()[0].parent.label;
  194. let province =
  195. this.$refs["refSubCat"].getCheckedNodes()[0].parent.parent.label;
  196. console.log(district,city,province,this.$refs["refSubCat"].getCheckedNodes()[0].parent, "dddddddd");
  197. this.city_name = city;
  198. this.point.lat = '';
  199. this.point.lng = '';
  200. }
  201. }
  202. },
  203. setSrcList(items) {
  204. return (this.srcList = [items]);
  205. },
  206. checkMore(index) {
  207. console.log(this.info[index]);
  208. if (this.info[index].close) {
  209. this.$set(this.info[index], "close", false);
  210. } else {
  211. this.$set(this.info[index], "close", true);
  212. }
  213. },
  214. focusInp() {
  215. let that = this;
  216. AMap.plugin("AMap.Autocomplete", function () {
  217. // 实例化Autocomplete
  218. var autoOptions = {
  219. //city 限定城市,默认全国
  220. city: that.city_name,
  221. input: "suggestId",
  222. };
  223. var autoComplete = new AMap.Autocomplete(autoOptions);
  224. AMap.event.addListener(autoComplete, "select", select); //注册监听,当选中某条记录时会触发
  225. });
  226. function select(e) {
  227. AMap.plugin("AMap.Geocoder", function () {
  228. var geocoder = new AMap.Geocoder({
  229. // city 指定进行编码查询的城市,支持传入城市名、adcode 和 citycode
  230. city: that.city,
  231. });
  232. //var lnglat = [116.396574, 39.992706]
  233. geocoder.getAddress(e.poi.location, function (status, result) {
  234. if (status === "complete" && result.info === "OK") {
  235. // result为对应的地理位置详细信息
  236. var point = {
  237. lat: e.poi.location.lat,
  238. lng: e.poi.location.lng,
  239. };
  240. var pos;
  241. if (result.regeocode.addressComponent.city == "") {
  242. pos = {
  243. address: e.poi.address,
  244. city: result.regeocode.addressComponent.province,
  245. province: result.regeocode.addressComponent.province,
  246. title: e.poi.name,
  247. point: point,
  248. };
  249. } else {
  250. pos = {
  251. address: e.poi.address,
  252. city: result.regeocode.addressComponent.city,
  253. province: result.regeocode.addressComponent.province,
  254. title: e.poi.name,
  255. point: point,
  256. };
  257. }
  258. // that.$store.commit("updateLocation", pos);
  259. // that.$store.commit("setLocation", pos);
  260. // myLocation = pos || {};
  261. that.getList(pos.city, point.lat, point.lng, "");
  262. } else {
  263. this.$message.error("请输入更详细的地址");
  264. }
  265. });
  266. });
  267. }
  268. },
  269. search() {
  270. if (this.optionsSelectValue == 2) {
  271. if(!this.deliverDialogInput) this.$message.error("请输入详细的地址");
  272. this.focusInp();
  273. } else {
  274. this.getList(
  275. this.city_name,
  276. this.point.lat,
  277. this.point.lng,
  278. this.deliverDialogInput
  279. );
  280. }
  281. },
  282. monitorPage() {
  283. this.page = val.page;
  284. this.getList(
  285. this.city_name,
  286. this.point.lat,
  287. this.point.lng,
  288. this.deliverDialogInput
  289. );
  290. },
  291. //高德坐标转百度(传入经度、纬度)
  292. bd_encrypt(gg_lng, gg_lat) {
  293. var X_PI = (Math.PI * 3000.0) / 180.0;
  294. var x = gg_lng,
  295. y = gg_lat;
  296. var z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * X_PI);
  297. var theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * X_PI);
  298. var bd_lng = z * Math.cos(theta) + 0.0065;
  299. var bd_lat = z * Math.sin(theta) + 0.006;
  300. return {
  301. lat: bd_lat,
  302. lng: bd_lng,
  303. };
  304. },
  305. getList(city, lat, lng, kwd) {
  306. let that = this;
  307. let p = {};
  308. if (lng) {
  309. p = this.bd_encrypt(lng, lat);
  310. }
  311. let json = {
  312. city_name: city,
  313. lat: p.lat || "",
  314. lng: p.lng || "",
  315. goods: that.$route.params.goods || [],
  316. kwd: kwd,
  317. };
  318. let _url = "plugin.package-deliver.frontend.deliver.getList";
  319. // const { store_id, groupStoreID } = this.$route.params;
  320. // if (this.$route.params.dispatch_id == 12 && (store_id || groupStoreID)) {
  321. // // 门店自提点,只返回该门店创建的自提点
  322. // json.store_id = store_id || groupStoreID;
  323. // _url = "plugin.package-deliver.frontend.store.deliver.getList";
  324. // }
  325. this.fun.$get(_url, json, ".").then(
  326. (response) => {
  327. if (response.result === 1) {
  328. // that.fun.setWXTitle(response.data.name);
  329. // that.isLoadMore = true;
  330. // that.total_page = response.data.list.last_page;
  331. // if (!that.total_page) {
  332. // that.total_page = 0;
  333. // }
  334. this.total = response.data.list.total;
  335. this.per_page = response.data.list.per_page;
  336. this.deliverName = response.data.name;
  337. this.optionsSelect[0].label = this.deliverName;
  338. this.info = response.data.list.data;
  339. } else {
  340. this.$message.error(response.msg);
  341. }
  342. },
  343. function (response) {
  344. console.log(response);
  345. }
  346. );
  347. },
  348. },
  349. };
  350. </script>
  351. <style lang="scss" scoped>
  352. .deliverDialogBox {
  353. background: #fff;
  354. padding: 0 10px;
  355. .top {
  356. display: flex;
  357. align-items: center;
  358. .searchBtn {
  359. width: 102px;
  360. height: 42px;
  361. background: #29ba9c;
  362. border-radius: 4px;
  363. font-size: 16px;
  364. color: #ffffff;
  365. text-align: center;
  366. line-height: 42px;
  367. margin-left: 20px;
  368. }
  369. .inp {
  370. width: 340px;
  371. }
  372. .deleverAndAdress {
  373. margin-right: 32px;
  374. }
  375. .CityTapBox {
  376. position: relative;
  377. .cascader {
  378. position: absolute;
  379. top: 0;
  380. left: 0;
  381. width: 100%;
  382. height: 100%;
  383. opacity: 0;
  384. }
  385. }
  386. .address {
  387. display: flex;
  388. align-items: center;
  389. margin-right: 20px;
  390. position: relative;
  391. img {
  392. width: 16px;
  393. height: 18px;
  394. margin-right: 8px;
  395. }
  396. }
  397. }
  398. .contenBox {
  399. padding: 35px 0;
  400. box-sizing: border-box;
  401. overflow: hidden;
  402. display: flex;
  403. flex-wrap: wrap;
  404. align-items: flex-start;
  405. .redListColor{
  406. border: 1px solid red;
  407. }
  408. .list {
  409. width: 472px;
  410. overflow: hidden;
  411. padding: 15px 22px;
  412. border: 1px solid #f0f0f0;
  413. border-radius: 4px;
  414. box-sizing: border-box;
  415. margin-right: 15px;
  416. margin-bottom: 15px;
  417. .top {
  418. display: flex;
  419. justify-content: space-between;
  420. align-items: center;
  421. .name {
  422. font-size: 18px;
  423. color: #333333;
  424. }
  425. .btn {
  426. font-size: 16px;
  427. color: #29ba9c;
  428. .el-icon-arrow-down {
  429. color: #29ba9c;
  430. }
  431. }
  432. }
  433. .adddress {
  434. width: 100%;
  435. text-align: left;
  436. color: #333333;
  437. margin-top: 10px;
  438. margin-bottom: 10px;
  439. display: -webkit-box;
  440. -webkit-box-orient: vertical;
  441. -webkit-line-clamp: 2;
  442. overflow: hidden;
  443. }
  444. .distance {
  445. font-size: 16px;
  446. color: #d7ab4b;
  447. text-align: right;
  448. }
  449. .timeContact {
  450. display: flex;
  451. justify-content: space-between;
  452. margin-top: 10px;
  453. .time,
  454. .phone {
  455. flex: 1;
  456. font-size: 14px;
  457. color: #666666;
  458. text-align: left;
  459. }
  460. }
  461. .thumbBox {
  462. margin-top: 10px;
  463. display: flex;
  464. .txt {
  465. font-size: 14px;
  466. color: #666666;
  467. margin-right: 11px;
  468. }
  469. .thumbLis {
  470. flex: 1;
  471. overflow-x: scroll;
  472. img {
  473. width: 70px;
  474. height: 70px;
  475. background: #e1e1e1;
  476. border-radius: 4px;
  477. }
  478. }
  479. .thumbLis::-webkit-scrollbar {
  480. width: 0 !important;
  481. }
  482. }
  483. }
  484. }
  485. }
  486. </style>