closeaddress.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. <template>
  2. <view>
  3. <u-navbar :is-back="true">
  4. <!-- #ifndef MP-WEIXIN -->
  5. <view style="width: 100%;text-align: center;letter-spacing: 2rpx;font-weight: bold;font-size: 30rpx;">
  6. <view v-if="indentType == 1||indentType == 2||indentType == 3">填写收货地址</view>
  7. <view v-if="indentType == 4">填写服务地址</view>
  8. </view>
  9. <!-- #endif -->
  10. <!-- #ifdef MP-WEIXIN -->
  11. <view class="slot-wrap">
  12. <view v-if="indentType == 1||indentType == 2||indentType == 3">填写收货地址</view>
  13. <view v-if="indentType == 4">填写服务地址</view>
  14. </view>
  15. <!-- #endif -->
  16. </u-navbar>
  17. <view class="content">
  18. <!-- 正文内容 -->
  19. <view class="takeaddress">
  20. <view class="part1">
  21. <view class="name">
  22. <u-field v-model="name" placeholder="联系人姓名" type="text" icon="account-fill"
  23. label-align="center">
  24. </u-field>
  25. </view>
  26. <view class="mobile">
  27. <u-field :maxlength="11" v-model="mobile" type="number" placeholder="联系电话" icon="phone-fill"
  28. label-align="center">
  29. </u-field>
  30. </view>
  31. <view class="address" @click="bindmap">
  32. <u-field v-model="cityaddress" placeholder="选择地址" :disabled="true" icon="map-fill"
  33. label-align="center">
  34. </u-field>
  35. </view>
  36. <view class="detailaddress">
  37. <u-field v-model="detailaddress" placeholder="详细地址" icon="map-fill" label-align="center">
  38. </u-field>
  39. </view>
  40. <view class="btn" @click="bindhelp">确定</view>
  41. </view>
  42. <view class="part2">
  43. <view v-if="oldlist.length>0">
  44. <view class="address1">常用地址</view>
  45. <view class="address_box" v-for="(item,index) in oldlist" :key="index" @click="goBack(item.addressId)">
  46. <view class="address_left">
  47. <u-icon name="map-fill"></u-icon>
  48. </view>
  49. <view class="address_right">
  50. <view class="add">
  51. {{item.address}}{{item.addressDetail}}
  52. </view>
  53. <view class="num">
  54. <view class="name">{{item.userName}}</view>
  55. <view class="number">{{item.userPhone}}</view>
  56. </view>
  57. </view>
  58. <view @tap.stop='deleteAddressList(item)' class="dete">删除</view>
  59. </view>
  60. </view>
  61. <!-- <view v-else>
  62. <view style="width: 50%;margin: 0 auto;">
  63. <image src="../../static/image/emety.png" style="width: 100%;height: 390rpx;"></image>
  64. </view>
  65. </view> -->
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </template>
  71. <script>
  72. export default {
  73. data() {
  74. return {
  75. mobile: '',
  76. name: '',
  77. cityaddress: '',
  78. detailaddress: '',
  79. latitude: '',
  80. longitude: '',
  81. oldlist: [],
  82. indentType: 1,
  83. current: 0,
  84. addressType: ''
  85. }
  86. },
  87. onLoad(e) {
  88. console.log(e)
  89. if (e.addressType) {
  90. this.addressType = e.addressType
  91. }
  92. this.indentType = e.index
  93. this.current = e.current
  94. this.oldAddress()
  95. },
  96. onShow() {
  97. },
  98. methods: {
  99. bindhelp() {
  100. let that = this
  101. let token = that.$queue.getData("token")
  102. if (!token) {
  103. uni.showToast({
  104. title: '请先登录',
  105. icon: 'none',
  106. duration: 2000
  107. });
  108. return;
  109. }
  110. if (that.mobile.length != 11) {
  111. uni.showToast({
  112. title: '请正确输入联系电话',
  113. icon: 'none',
  114. duration: 2000
  115. });
  116. return;
  117. }
  118. if (!/^1[3456789]\d{9}$/.test(that.mobile)) {
  119. uni.showToast({
  120. title: '请正确输入联系电话',
  121. icon: 'none',
  122. duration: 2000
  123. });
  124. return;
  125. }
  126. if (that.name == '') {
  127. uni.showToast({
  128. title: '请输入联系人姓名',
  129. icon: 'none',
  130. duration: 2000
  131. });
  132. return;
  133. }
  134. if (that.cityaddress == '') {
  135. uni.showToast({
  136. title: '请输入收货地址',
  137. icon: 'none',
  138. duration: 2000
  139. });
  140. return;
  141. }
  142. if (that.detailaddress == '') {
  143. uni.showToast({
  144. title: '请输入详细地址',
  145. icon: 'none',
  146. duration: 2000
  147. });
  148. return;
  149. }
  150. let userId = that.$queue.getData('userId');
  151. let data = {
  152. type: that.type,
  153. userPhone: that.mobile,
  154. userName: that.name,
  155. address: that.cityaddress, ///注释
  156. addressDetail: that.detailaddress,
  157. addressLatitude: that.latitude,
  158. addressLongitude: that.longitude,
  159. userId: userId
  160. }
  161. that.$Request.postJson('/app/indent/addUserAddress', data).then(res => {
  162. if (res.code == 0) {
  163. that.$queue.showToast("地址保存成功!");
  164. // uni.navigateBack();
  165. setTimeout(function(){
  166. that.goBack(res.data)
  167. },500)
  168. } else {
  169. that.$queue.showToast(res.msg);
  170. }
  171. });
  172. },
  173. // 点击地址返回上一页
  174. goBack(e) {
  175. console.log(e)
  176. uni.setStorageSync('addressId',e)
  177. uni.setStorageSync('addressType',this.addressType)
  178. setTimeout(function(){
  179. uni.navigateBack()
  180. },10)
  181. },
  182. bindback(e) {
  183. let address = uni.getStorageSync('closeAddress')
  184. console.log(e)
  185. let add = {
  186. addressId: e.addressId,
  187. deliveryUserPhone: e.userPhone,
  188. deliveryUserName: e.userName,
  189. deliveryAddress: e.address, ///注释
  190. deilveryAddressDetail: e.addressDetail,
  191. userId: e.userId,
  192. deliveryAddressLatitude: e.addressLatitude,
  193. deliveryAddressLongitude: e.addressLongitude
  194. }
  195. if (this.indentType == 1) {
  196. address.data2 = add
  197. uni.navigateTo({
  198. url: '/pages/Helpsend/Helpsend?index=' + this.indentType
  199. })
  200. } else if (this.indentType == 2) {
  201. address.data2 = add
  202. uni.navigateTo({
  203. url: '/pages/Helpsend/Helpsend?index=' + this.indentType
  204. })
  205. } else if (this.indentType == 3 && this.current == 0) {
  206. address.data3 = add
  207. uni.navigateTo({
  208. url: '/pages/Helppay/Helppay?index=' + this.indentType + '&current=' + this.current
  209. })
  210. } else if (this.indentType == 3 && this.current == 1) {
  211. address.data4 = add
  212. uni.navigateTo({
  213. url: '/pages/Helppay/Helppay?index=' + this.indentType + '&current=' + this.current
  214. })
  215. } else if (this.indentType == 4) {
  216. address.citydata = add
  217. uni.navigateTo({
  218. url: '/pages/Cityservice/Cityservice?index=' + this.indentType
  219. })
  220. }
  221. uni.setStorageSync("closeAddress", address)
  222. // uni.navigateBack()
  223. // uni.navigateBack()
  224. // if (this.indentType == 1) {
  225. // uni.navigateTo({
  226. // url: '/pages/Helpsend/Helpsend?index=' + this.indentType
  227. // })
  228. // }
  229. },
  230. bindmap() {
  231. var that = this
  232. // if (that.ciaddress == '') {
  233. uni.chooseLocation({
  234. success: function(res) {
  235. // console.log('位置名称:' + res.name);
  236. // console.log('详细地址:' + res.address);
  237. // console.log('纬度:' + res.latitude);
  238. // console.log('经度:' + res.longitude);
  239. that.detailaddress = res.name
  240. that.latitude = res.latitude
  241. that.longitude = res.longitude
  242. that.shengcheng(res.longitude, res.latitude)
  243. }
  244. });
  245. // }
  246. },
  247. shengcheng(longitude, latitude) {
  248. let data = {
  249. lat: latitude,
  250. lng:longitude
  251. };
  252. this.$Request.getT('/app/Login/selectCity').then(res => {
  253. // console.log(res)
  254. if (res.code === 0) {
  255. this.cityaddress = res.data.province + res.data.city + res.data.district
  256. // console.log(this.address)
  257. }
  258. });
  259. },
  260. oldAddress() {
  261. this.$Request.getT('/app/indent/findUserAddress').then(res => {
  262. // console.log(res)
  263. if (res.code === 0) {
  264. this.oldlist = res.data
  265. console.log(this.oldlist)
  266. }
  267. });
  268. },
  269. deleteAddressList(e) {
  270. console.log(e)
  271. let data = {
  272. userName: e.userName,
  273. userPhone: e.userPhone,
  274. address: e.address,
  275. addressDetail: e.addressDetail,
  276. addressLatitude: e.addressLatitude,
  277. addressLongitude: e.addressLongitude,
  278. userId: e.userId,
  279. addressId: e.addressId,
  280. addressDefault: e.addressDefault
  281. }
  282. uni.showModal({
  283. title: '温馨提示',
  284. content: '您确定要删除此地址信息吗?',
  285. showCancel: true,
  286. cancelText: '取消',
  287. confirmText: '确认',
  288. success: res => {
  289. if (res.confirm) {
  290. this.$Request.getT('/app/indent/delUserAddress', data).then(res => {
  291. console.log(res)
  292. if (res.code == 0) {
  293. this.$queue.showToast("删除成功!");
  294. this.oldAddress();
  295. } else {
  296. this.$queue.showToast(res.msg);
  297. }
  298. });
  299. }
  300. }
  301. });
  302. },
  303. }
  304. }
  305. </script>
  306. <style>
  307. body {
  308. background: #F5F5F5;
  309. }
  310. .dete {
  311. /* flex: 2; */
  312. width: 15%;
  313. text-align: center;
  314. background: #FF7F00;
  315. height: 60rpx;
  316. line-height: 60rpx;
  317. color: #ffffff;
  318. letter-spacing: 1rpx;
  319. border-radius: 15rpx;
  320. margin-right: 20rpx;
  321. }
  322. .slot-wrap {
  323. /* display: flex; */
  324. /* align-items: center; */
  325. /* 如果您想让slot内容占满整个导航栏的宽度 */
  326. /* flex: 1; */
  327. /* 如果您想让slot内容与导航栏左右有空隙 */
  328. /* padding: 0 30rpx; */
  329. width: 100%;
  330. text-align: center;
  331. margin-left: 100rpx;
  332. letter-spacing: 2rpx;
  333. font-weight: bold;
  334. font-size: 30rpx;
  335. }
  336. .takeaddress {
  337. width: 100%;
  338. }
  339. .part1 {
  340. width: 100%;
  341. background: #ffffff;
  342. margin-top: 24rpx;
  343. padding-bottom: 40upx;
  344. }
  345. .btn {
  346. width: 90%;
  347. height: 80upx;
  348. background: #FF7F00;
  349. border-radius: 14upx;
  350. margin: 0 auto;
  351. color: white;
  352. text-align: center;
  353. line-height: 80upx;
  354. letter-spacing: 2upx;
  355. margin-top: 40upx;
  356. }
  357. .part2 {
  358. width: 100%;
  359. background: #ffffff;
  360. margin-top: 10upx;
  361. }
  362. .address1 {
  363. width: 90%;
  364. margin: 0 auto;
  365. font-size: 37rpx;
  366. font-weight: bold;
  367. padding-top: 30upx;
  368. }
  369. .address_box {
  370. display: flex;
  371. padding-bottom: 30upx;
  372. padding-top: 30upx;
  373. width: 100%;
  374. }
  375. .address_left {
  376. /* flex: 2; */
  377. width: 15%;
  378. display: flex;
  379. justify-content: center;
  380. align-items: center;
  381. }
  382. .address_right {
  383. /* flex: 10; */
  384. width: 80%;
  385. font-size: 31rpx;
  386. overflow: hidden;
  387. }
  388. .add {
  389. /* color: #333333; */
  390. /* font-size: 31rpx; */
  391. /* letter-spacing: 1upx; */
  392. }
  393. .name {
  394. display: inline;
  395. font-size: 34rpx;
  396. color: #999999;
  397. }
  398. .number {
  399. display: initial;
  400. color: #999999;
  401. font-size: 34rpx;
  402. margin-left: 30upx;
  403. }
  404. .u-icon__icon {
  405. font-size: 45rpx !important;
  406. }
  407. .u-field {
  408. padding: 35rpx 28rpx !important;
  409. }
  410. .u-label {
  411. flex: 0 0 42px !important;
  412. }
  413. .u-field__input-wrap {
  414. font-size: 30rpx !important;
  415. }
  416. .u-textarea-class {
  417. font-size: 30rpx !important;
  418. }
  419. </style>