area.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <style>
  2. page{background: #f1f1f1f1;}
  3. .user-line {padding: 0 15px;height: 50px;background: #fff;border-top: 1px #f5f5f5 solid;display: flex;align-items: center}
  4. .ul-left {color: #585858;font-size: 14px}
  5. .ul-right {width: 60%;margin-left: auto;display: flex;align-items: center;justify-content: flex-end}
  6. .ulr-name {color: #9b9b9b;font-size: 13px}
  7. .ulr-img {width: 16px;
  8. height: 16px;
  9. margin-left: 10px}
  10. .ulr-img image {width: 100%;height: 100%;}
  11. .update-btn {
  12. width: 90%;
  13. height: 40px;
  14. text-align: center;
  15. line-height: 40px;
  16. margin: 30px auto;
  17. background: #db292b;
  18. color: #fff;
  19. border-radius: 100px;
  20. font-size: 16px;
  21. }
  22. </style>
  23. <template>
  24. <view class="m-app">
  25. <view class="user-line" @tap="showMulLinkageThreePicker">
  26. <view class="ul-left"><text>所在地区</text></view>
  27. <view class="ul-right">
  28. <view class="ulr-name">
  29. <text>{{data.region ? data.region : "请选择:省-市-区"}}</text>
  30. </view>
  31. <view class="ulr-img">
  32. <image src="/static/img/ic_next.png"></image>
  33. </view>
  34. </view>
  35. </view>
  36. <button class="nt update-btn" @tap="formSubmit" >确认保存</button>
  37. <mpvue-city-picker :themeColor="themeColor" ref="mpvueCityPicker" :pickerValueDefault="cityPickerValueDefault"
  38. @onCancel="onCancel" @onConfirm="onConfirm"></mpvue-city-picker>
  39. </view>
  40. </template>
  41. <script>
  42. import {mapState,mapMutations} from 'vuex'
  43. import mpvueCityPicker from '../../../components/mpvue-citypicker/mpvueCityPicker.vue'
  44. export default {
  45. components: {
  46. 'mpvue-city-picker': mpvueCityPicker
  47. },
  48. computed: mapState(['user']),
  49. data() {
  50. return {
  51. val:0,
  52. cityPickerValueDefault: [0, 0, 0],
  53. themeColor: '#db292b',
  54. data: {region:"",City:0}
  55. }
  56. },
  57. onLoad(options) {
  58. var val = options.val || "";
  59. this.val = val;
  60. this.data.region = val;
  61. },
  62. methods: {
  63. // 省市区选择
  64. showMulLinkageThreePicker() {
  65. this.$refs.mpvueCityPicker.show()
  66. },
  67. onCancel(e) {
  68. this.data.region = "";
  69. },
  70. onConfirm(e) {
  71. this.data.region = e.label;
  72. this.data.City = e.cityCode;
  73. },
  74. radioChange:function(e){
  75. this.val = parseInt(e.detail.value);
  76. },
  77. formSubmit:function(){
  78. var that = this , token = this.user.token;
  79. if(this.data.region == ""){
  80. this.utils.Tip("请选择省市区");
  81. return;
  82. }
  83. let formData = {};
  84. formData.val = this.data.City;
  85. formData.token = token;
  86. formData.code = "region_id";
  87. this.utils.loadIng("提交中..");
  88. this
  89. .request
  90. .post("userInfoSave",formData)
  91. .then(res=>{
  92. uni.hideLoading();
  93. if(res.code == 200) {
  94. this.utils.Tip(res.msg);
  95. setTimeout(function(){ uni.navigateBack();},1000);
  96. }else{
  97. that.utils.Tip(res.msg);
  98. }
  99. }).catch(function(){
  100. uni.hideLoading();
  101. that.utils.Tip("网络错误,请稍后尝试");
  102. });
  103. }
  104. },
  105. onBackPress() {
  106. if (this.$refs.mpvueCityPicker.showPicker) {
  107. this.$refs.mpvueCityPicker.pickerCancel();
  108. }
  109. },
  110. onUnload() {
  111. if (this.$refs.mpvueCityPicker.showPicker) {
  112. this.$refs.mpvueCityPicker.pickerCancel()
  113. }
  114. }
  115. }
  116. </script>