info.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <view>
  3. <view class="alter_info">请选择您药店/诊所所在城市,选择后不可更改,请谨慎选择</view>
  4. <view class="form" >
  5. <!-- 地区代表表单 -->
  6. <form class="info_form">
  7. <view class="form_group">
  8. <view class="group_title">所在城市:</view>
  9. <view class="group_box">
  10. <picker mode="multiSelector" class="form_ctrl" :range="cityArray" @columnchange="cityChange" @change="cityFinish" >
  11. <view class="area_text">
  12. <text v-if="requestParam.province"> {{requestParam.province}} </text>
  13. <text v-if="requestParam.city"> / {{requestParam.city}} </text>
  14. </view>
  15. </picker>
  16. </view>
  17. </view>
  18. <button @click="toApply" class="submit_btn" >提交</button>
  19. </form>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import {getProvinces,getMyCity} from "../../utils/city";
  25. export default {
  26. data() {
  27. return {
  28. requestParam:{
  29. province:"",
  30. city:"",
  31. },
  32. cityArray: [[],[]],
  33. cityValue: [0,0],
  34. }
  35. },
  36. onLoad(){
  37. // 替换对应的数据
  38. this.cityArray.splice(0,1,getProvinces());
  39. this.cityArray.splice(1,1,getMyCity(this.cityValue[0]));
  40. // 默认地址
  41. this.requestParam.province = this.cityArray[0][this.cityValue[0]]
  42. this.requestParam.city = this.cityArray[1][this.cityValue[1]];
  43. },
  44. onShow(){
  45. // 登录信息
  46. if( !this.$checkAccess.alterLogin() ) return ;
  47. },
  48. methods: {
  49. toApply(){
  50. // 登录信息
  51. if( !this.$checkAccess.alterLogin() ) return ;
  52. // 请求状态
  53. uni.showLoading({mask:true});
  54. // 授权成功以后,调用绑定
  55. this.$http.request('api/custom/set_city',this.requestParam,'post').then((re)=>{
  56. // 关闭
  57. uni.hideLoading();
  58. // 成功的话
  59. if( re.code != 'success' ){
  60. // 跳转
  61. uni.showToast({title: re.msg,icon:"none"});
  62. return;
  63. }
  64. uni.switchTab({url: '/pages/user/index'});
  65. });
  66. },
  67. cityChange(e){
  68. // 替换三个选项
  69. this.cityValue.splice(e.detail.column,1,e.detail.value);
  70. // 下一级设置为0
  71. if( e.detail.column == 0 ){
  72. this.cityValue.splice(1,1,0);
  73. this.cityValue.splice(2,1,0);
  74. }
  75. if( e.detail.column == 1 ){
  76. this.cityValue.splice(2,1,0);
  77. }
  78. // 替换对应的数据
  79. this.cityArray.splice(0,1,getProvinces());
  80. this.cityArray.splice(1,1,getMyCity(this.cityValue[0]));
  81. },
  82. cityFinish(e){
  83. this.requestParam.city_id = this.cityArray[1][this.cityValue[1]];
  84. },
  85. }
  86. }
  87. </script>
  88. <style lang="less">
  89. .alter_info{
  90. display: block;
  91. color: #E03519;
  92. font-size: 20rpx;
  93. overflow: hidden;
  94. margin: 20rpx auto;
  95. background: #FFFFFF;
  96. line-height: 40rpx;
  97. padding: 35rpx 35rpx;
  98. text-align: center;
  99. }
  100. .info_form{
  101. display: block;
  102. overflow: hidden;
  103. padding: 20rpx 0rpx;
  104. background: #FFFFFF;
  105. .form_group{
  106. display: block;
  107. overflow: hidden;
  108. line-height: 60rpx;
  109. padding: 20rpx 35rpx;
  110. .group_title{
  111. float: left;
  112. width: 160rpx;
  113. display: block;
  114. overflow: hidden;
  115. font-size: 30rpx;
  116. margin-right: 20rpx;
  117. }
  118. .group_box{
  119. width: 480rpx;
  120. float: left;
  121. display: block;
  122. .form_ctrl{
  123. height: 56rpx;
  124. font-size: 24rpx;
  125. padding: 0rpx 20rpx;
  126. line-height: 56rpx;;
  127. border: 2rpx solid #DDDDDD;
  128. }
  129. .area_text{
  130. width: 446rpx;
  131. font-size: 20rpx;
  132. overflow: hidden;
  133. white-space: nowrap;
  134. text-overflow: ellipsis;
  135. }
  136. .group_image{
  137. width: 200rpx;
  138. height: 200rpx;
  139. }
  140. .choose_image{
  141. display: block;
  142. width: 200rpx;
  143. height: 200rpx;
  144. font-size: 38rpx;
  145. text-align: center;
  146. line-height: 200rpx;
  147. border: 2rpx solid #DDDDDD;
  148. }
  149. }
  150. }
  151. .submit_btn{
  152. color: #FFFFFF;
  153. width: 220rpx;
  154. height: 80rpx;
  155. display: block;
  156. font-size: 30rpx;
  157. padding: 0rpx 0rpx;
  158. line-height: 80rpx;
  159. margin: 50rpx auto;
  160. background-color: forestgreen;
  161. }
  162. }
  163. </style>