多租户商城-商户小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

478 lines
14 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <!-- 编辑/添加地址 -->
  3. <view class="container flex-center flex-column">
  4. <global-loading />
  5. <!-- #ifdef MP-WEIXIN -->
  6. <!-- <view class="wxAddress flex-items flex-end" v-if="type == 1">-->
  7. <!-- <view class="wxBtnBox flex-items" @click="addAddressWx">-->
  8. <!-- <image class="" src="http://36.138.125.206:8081/ceres-local-file/static/images/withdraw.png"></image>-->
  9. <!-- </view>-->
  10. <!-- </view>-->
  11. <!-- #endif -->
  12. <view class="addressBack-box">
  13. <view class="consignee-box bor-line-D3D4DE">
  14. <input v-model="addressData.username" maxlength="20" class="fs32" placeholder-class="consignee" :placeholder="$t('common.returnperson')" />
  15. </view>
  16. <view class="iphoneNum-box bor-line-D3D4DE">
  17. <input type="number" v-model="addressData.phone" maxlength="11" class="fs32" placeholder-class="iphoneNum" :placeholder="$t('common.login_phone_mode')" />
  18. </view>
  19. <view @click="locationClick" class="location-box bor-line-D3D4DE flex-row-plus flex-sp-between flex-items">
  20. <view class="fs32 location">{{$t('common.location')}}</view>
  21. <view class="locationBox">
  22. <!-- <city-select v-model="locationShowFalg" @city-change="cityChange"></city-select>-->
  23. <u-picker-cere mode="region" v-model="locationShowFalg" @confirm="cityChange" :default-region='addressData.defaultRegion' title="所在地"></u-picker-cere>
  24. <text class="fs32" v-model="addressData.ssqText">{{addressData.ssqText}}</text>
  25. <image class="arrow mar-left-20 mar-top-8" src="http://36.138.125.206:8081/ceres-local-file/image/icon_common_grey_forward.png"></image>
  26. </view>
  27. </view>
  28. <view class="detailAddress-box">
  29. <input class="fs32" v-model="addressData.address" maxlength="60" placeholder-class="detailAddress" :placeholder="$t('common.location_detail_hint')" />
  30. </view>
  31. </view>
  32. <view class="addressTagBack-box">
  33. <view @click="addressTagClick" class="addressTag-box bor-line-D3D4DE flex-row-plus flex-sp-between flex-items">
  34. <view class="fs32 addressTag">{{$t('common.addresstag')}}</view>
  35. <view class="flex-items">
  36. <text class="fs32" v-model="tag">{{tag}}</text>
  37. <image class="arrow mar-left-20 mar-top-8" src="http://36.138.125.206:8081/ceres-local-file/image/address_add_forward.png"></image>
  38. </view>
  39. </view>
  40. <view class="defaultState-box flex-row-plus flex-sp-between flex-items">
  41. <view class="fs32 defaultState">{{$t('common.addressdefault')}}</view>
  42. <u-switch v-model="ifDefault" active-color="#252744" inactive-color="#bcbdc6"></u-switch>
  43. </view>
  44. </view>
  45. <view class="deleteAddress-box" @click="delAddress" v-if="type == 2">
  46. <text class="font-color-F54639">{{$t('common.deleteaddress')}}</text>
  47. </view>
  48. <view class="saveAddress-box">
  49. <view class="saveAddress" v-if="type == 1 || type == 3" @click="addAddressClick">{{$t('common.save')}}</view>
  50. <view class="saveAddress" v-else @click="saveAddressClick">{{$t('common.save')}}</view>
  51. </view>
  52. <!-- 所在地弹窗 -->
  53. <!-- <u-select v-model="locationShowFalg" safe-area-inset-bottom="true" mode="mutil-column-auto" :list="locationList" @confirm="locationConfirm" title="所在地"></u-select> -->
  54. <!-- 所在地弹窗 -->
  55. <!-- <u-select v-model="addressTagShowFalg" mode="single-column" :list="addressTagList" @confirm="addressTagconfirm" title="地址标签"></u-select>-->
  56. <u-picker-cere mode="selector" v-model="addressTagShowFalg" :range="addressTagList" range-key="label" @confirm="addressTagconfirm" title="地址标签" :default-selector="[addressTagIndex]"></u-picker-cere>
  57. </view>
  58. </template>
  59. <script>
  60. // import citySelect from './u-city-select.vue';
  61. const NET = require('../../utils/request')
  62. const API = require('../../config/api')
  63. export default {
  64. // components: {
  65. // citySelect
  66. // },
  67. data() {
  68. return {
  69. show: false,
  70. type: 1, // 1.添加新地址 2.编辑收货地址
  71. locationShowFalg:false,
  72. locationList: [],
  73. locationName:'',
  74. provinceName:'',
  75. cityName:'',
  76. districtName:'',
  77. addressTagList: [
  78. {
  79. value: '1',
  80. label: this.$t('common.home')
  81. },
  82. {
  83. value: '2',
  84. label: this.$t('common.company')
  85. },
  86. {
  87. value: '3',
  88. label: this.$t('common.school')
  89. }
  90. ],
  91. addressTagShowFalg:false,
  92. areaList:[],
  93. username:'',
  94. phone:'',
  95. ssqText:'',
  96. address:'',
  97. tag:'',
  98. ifDefault: 0,
  99. province:'',
  100. city:'',
  101. area:'',
  102. id:'',
  103. ordertype:0,
  104. editAddress:{},
  105. addressTagIndex: 0,
  106. // defaultRegion: [],
  107. addressData: {
  108. username: '',
  109. phone: '',
  110. ssqText: '',
  111. address: '',
  112. defaultRegion: [],
  113. city:'',
  114. province:'',
  115. }
  116. }
  117. },
  118. onLoad(options) {
  119. this.type = options.type
  120. if(options.ordertype == 1){
  121. this.ordertype = 1
  122. }
  123. let receiveId = options.receiveId
  124. this.id = receiveId
  125. if(this.type == 2){
  126. // uni.showLoading({
  127. // mask: true,
  128. // title: '请稍后...',
  129. // })
  130. NET.request(API.receiveGetInfo,{receiveId:receiveId},"GET").then(res => {
  131. this.editAddress = res.data
  132. this.addressData.username = this.editAddress.receiveName
  133. this.addressData.phone = this.editAddress.receivePhone
  134. this.addressData.ssqText = this.editAddress.receiveAdress
  135. this.addressData.address = this.editAddress.address
  136. this.tag = this.editAddress.label
  137. for(let i=0;i<this.addressTagList.length;i++){
  138. if(this.addressTagList[i].label === this.tag){
  139. this.addressTagIndex = i
  140. }
  141. }
  142. this.ifDefault = this.editAddress.ifDefault
  143. this.addressData.defaultRegion = this.addressData.ssqText.split("-")
  144. this.addressData.province = this.addressData.defaultRegion[0]
  145. this.addressData.city = this.addressData.defaultRegion[1]
  146. this.addressData.area = this.addressData.defaultRegion[2]
  147. this.addressData.id = this.editAddress.receiveId
  148. uni.hideLoading()
  149. }).catch(res => {
  150. })
  151. }
  152. if (this.type == 3) {
  153. let obj = JSON.parse(options.wxAddressData)
  154. this.addressData = obj
  155. // this.username = obj.username
  156. // this.phone = obj.phone
  157. // this.ssqText = obj.ssqText
  158. // this.defaultRegion = obj.defaultRegion
  159. // this.address = obj.address
  160. // this.province = obj.provinceName
  161. // this.city = obj.cityName
  162. }
  163. if(this.editAddress != ''){
  164. uni.removeStorageSync('editAddress')
  165. }
  166. },
  167. methods: {
  168. cityChange(e) {
  169. this.addressData.ssqText = e.province.label + '-' + e.city.label + '-' + e.area.label;
  170. this.addressData.province = e.province.label
  171. this.addressData.city = e.city.label
  172. this.addressData.area = e.area.label
  173. },
  174. locationClick(){
  175. this.locationShowFalg = true
  176. },
  177. locationConfirm(e) {
  178. this.provinceName = e[0].label
  179. this.cityName = e[1].label
  180. this.districtName = e[2].label
  181. this.locationDot = '·'
  182. },
  183. addressTagClick(){
  184. this.addressTagShowFalg = true
  185. },
  186. addressTagconfirm(index){
  187. this.tag = this.addressTagList[index].label
  188. },
  189. //编辑地址
  190. saveAddressClick(){
  191. let phoneCodeVerification = /^[1][3-9][0-9]{9}$/;
  192. if(this.addressData.username==''){
  193. uni.showToast({
  194. title: this.$t('common.returnperson_empty'),
  195. duration: 2000,
  196. icon:'none'
  197. });
  198. }else if(this.addressData.phone ==''){
  199. uni.showToast({
  200. title: this.$t('common.phonenumber_empty'),
  201. duration: 2000,
  202. icon:'none'
  203. });
  204. }else if(!phoneCodeVerification.test(this.addressData.phone)){
  205. uni.showToast({
  206. title: this.$t('common.phonenumber_error'),
  207. duration: 2000,
  208. icon:'none'
  209. });
  210. }else if(this.addressData.province==''||this.addressData.city==''){
  211. uni.showToast({
  212. title: this.$t('common.location_empty'),
  213. duration: 2000,
  214. icon:'none'
  215. });
  216. }else if(this.addressData.address==''){
  217. uni.showToast({
  218. title: this.$t('common.location_detail_empty'),
  219. duration: 2000,
  220. icon:'none'
  221. });
  222. }else{
  223. NET.request(API.AddresUpdate,{
  224. receiveId: this.id,
  225. receiveName: this.addressData.username,
  226. receivePhone: this.addressData.phone,
  227. receiveAdress: this.addressData.ssqText,
  228. address:this.addressData.address,
  229. label:this.tag,
  230. ifDefault:this.ifDefault ? 1 : 0
  231. },'POST').then(res => {
  232. uni.navigateBack({
  233. delta: 1
  234. });
  235. uni.removeStorageSync('editAddress');
  236. }).catch(res => {
  237. })
  238. }
  239. },
  240. //新增地址
  241. addAddressClick(){
  242. let phoneCodeVerification = /^[1][3-9][0-9]{9}$/;
  243. if(this.addressData.username==''){
  244. uni.showToast({
  245. title: this.$t('common.returnperson_empty'),
  246. duration: 2000,
  247. icon:'none'
  248. });
  249. }else if(this.addressData.phone==''){
  250. uni.showToast({
  251. title: this.$t('common.phonenumber_empty'),
  252. duration: 2000,
  253. icon:'none'
  254. });
  255. }else if(!phoneCodeVerification.test(this.addressData.phone)){
  256. uni.showToast({
  257. title: this.$t('common.phonenumber_error'),
  258. duration: 2000,
  259. icon:'none'
  260. });
  261. }else if(this.addressData.province==''||this.addressData.city==''){
  262. uni.showToast({
  263. title: this.$t('common.location_empty'),
  264. duration: 2000,
  265. icon:'none'
  266. });
  267. }else if(this.addressData.address==''){
  268. uni.showToast({
  269. title: this.$t('common.location_detail_empty'),
  270. duration: 2000,
  271. icon:'none'
  272. });
  273. }else{
  274. NET.request(API.AddresAdd,
  275. {
  276. receiveName: this.addressData.username,
  277. receivePhone: this.addressData.phone,
  278. receiveAdress: this.addressData.ssqText,
  279. address:this.addressData.address,
  280. label:this.tag,
  281. ifDefault: this.ifDefault ? 1 : 0
  282. },'POST').then(res => {
  283. if(this.ordertype == 1){
  284. uni.setStorageSync('receiveItem', res.data)
  285. uni.navigateBack({
  286. delta: 2
  287. });
  288. }else{
  289. uni.navigateBack({
  290. delta: 1
  291. });
  292. }
  293. }).catch(res => {
  294. })
  295. }
  296. },
  297. // addAddressWx() {
  298. // let self = this
  299. // uni.chooseAddress({
  300. // success(res){
  301. // self.username = res.userName
  302. // self.phone = res.telNumber
  303. // self.ssqText = `${res.provinceName}-${res.cityName}-${res.countyName}`
  304. // self.defaultRegion = self.ssqText.split("-")
  305. // self.address = res.detailInfo
  306. // self.province = res.provinceName
  307. // self.city = res.cityName
  308. // }
  309. // })
  310. // },
  311. //删除地址
  312. delAddress(){
  313. uni.showModal({
  314. title: this.$t('common.notice_dialog_title'),
  315. content: this.$t('common.removeaddress_tips'),
  316. confirmText:this.$t('common.sure'),
  317. cancelText:this.$t('common.cancel'),
  318. success: (res)=> {
  319. if (res.confirm) {
  320. this.subm()
  321. } else if (res.cancel) {
  322. }
  323. }
  324. })
  325. },
  326. subm(){
  327. NET.request(API.AddresDelete,{
  328. receiveId: this.id
  329. },'POST').then(res => {
  330. if(res.code === "200"){
  331. uni.navigateBack({
  332. delta: 1
  333. });
  334. }
  335. }).catch(res => {
  336. })
  337. }
  338. }
  339. }
  340. </script>
  341. <style lang="scss">
  342. page{
  343. background-color: #FAFAFA;
  344. }
  345. .container{
  346. .addressBack-box{
  347. background-color: #FFFFFF;
  348. padding: 30upx 30upx;
  349. .consignee-box{
  350. padding-bottom: 36upx;
  351. width: 690upx;
  352. margin-top: 20upx;
  353. .consignee{
  354. color: #90919C;
  355. font-size: 32rpx;
  356. }
  357. }
  358. .iphoneNum-box{
  359. padding-bottom: 36upx;
  360. width: 690upx;
  361. margin-top: 36upx;
  362. .iphoneNum{
  363. color: #90919C;
  364. font-size: 32rpx;
  365. }
  366. }
  367. .location-box{
  368. padding-bottom: 36upx;
  369. width: 690upx;
  370. margin-top: 36upx;
  371. .location{
  372. color: #90919C;
  373. font-size: 32rpx;
  374. }
  375. .locationBox {
  376. display: flex;
  377. align-items: center;
  378. }
  379. }
  380. .detailAddress-box{
  381. padding-bottom: 36upx;
  382. width: 690upx;
  383. margin-top: 36upx;
  384. input{
  385. width: 100%;
  386. }
  387. .detailAddress{
  388. color: #90919C;
  389. font-size: 32rpx;
  390. }
  391. }
  392. }
  393. .addressTagBack-box{
  394. background-color: #FFFFFF;
  395. padding: 30upx 30upx;
  396. margin-top: 20upx;
  397. .addressTag-box{
  398. padding-bottom: 36upx;
  399. width: 690upx;
  400. .addressTag{
  401. color: #90919C;
  402. font-size: 32rpx;
  403. }
  404. }
  405. .defaultState-box{
  406. padding-bottom: 10upx;
  407. width: 690upx;
  408. margin-top: 36upx;
  409. .defaultState{
  410. color: #90919C;
  411. font-size: 32rpx;
  412. }
  413. }
  414. }
  415. .arrow{
  416. width: 16rpx;
  417. height: 28rpx;
  418. }
  419. .saveAddress-box{
  420. position: fixed;
  421. bottom: 50upx;
  422. left: 30upx;
  423. .saveAddress{
  424. width: 690upx;
  425. height: 98upx;
  426. text-align: center;
  427. line-height: 98upx;
  428. background: #252744;
  429. border-radius: 50rpx;
  430. color: #FFFFFF;
  431. }
  432. }
  433. .wxAddress {
  434. height: 80rpx;
  435. text-align: center;
  436. line-height: 80rpx;
  437. color: #90919C;
  438. .wxBtnBox {
  439. width: 100rpx;
  440. height: 80rpx;
  441. image {
  442. width: 80rpx;
  443. height: 80rpx;
  444. }
  445. }
  446. }
  447. }
  448. .deleteAddress-box{
  449. background-color: #FFFFFF;
  450. padding: 30upx 30upx;
  451. margin-top: 20upx;
  452. }
  453. .content{
  454. font-size: 35rpx;
  455. width: 500rpx;
  456. .btn{
  457. margin-bottom: 20rpx;
  458. width: 200rpx;
  459. background-image: linear-gradient( 135deg, #FFA100 10%, #FF7911 100%);
  460. }
  461. }
  462. </style>
  463. <style scoped>
  464. .addressBack-box /deep/ .u-tab-item{
  465. color: #C5AA7B !important;
  466. font-weight: 400 !important;
  467. }
  468. .addressBack-box /deep/ .u-tab-bar {
  469. background-color: #C5AA7B !important;
  470. }
  471. </style>