info.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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.province = this.cityArray[0][this.cityValue[0]];
  84. this.requestParam.city = this.cityArray[1][this.cityValue[1]];
  85. },
  86. }
  87. }
  88. </script>
  89. <style lang="less">
  90. .alter_info{
  91. display: block;
  92. color: #E03519;
  93. font-size: 20rpx;
  94. overflow: hidden;
  95. margin: 20rpx auto;
  96. background: #FFFFFF;
  97. line-height: 40rpx;
  98. padding: 35rpx 35rpx;
  99. text-align: center;
  100. }
  101. .info_form{
  102. display: block;
  103. overflow: hidden;
  104. padding: 20rpx 0rpx;
  105. background: #FFFFFF;
  106. .form_group{
  107. display: block;
  108. overflow: hidden;
  109. line-height: 60rpx;
  110. padding: 20rpx 35rpx;
  111. .group_title{
  112. float: left;
  113. width: 160rpx;
  114. display: block;
  115. overflow: hidden;
  116. font-size: 30rpx;
  117. margin-right: 20rpx;
  118. }
  119. .group_box{
  120. width: 480rpx;
  121. float: left;
  122. display: block;
  123. .form_ctrl{
  124. height: 56rpx;
  125. font-size: 24rpx;
  126. padding: 0rpx 20rpx;
  127. line-height: 56rpx;;
  128. border: 2rpx solid #DDDDDD;
  129. }
  130. .area_text{
  131. width: 446rpx;
  132. font-size: 20rpx;
  133. overflow: hidden;
  134. white-space: nowrap;
  135. text-overflow: ellipsis;
  136. }
  137. .group_image{
  138. width: 200rpx;
  139. height: 200rpx;
  140. }
  141. .choose_image{
  142. display: block;
  143. width: 200rpx;
  144. height: 200rpx;
  145. font-size: 38rpx;
  146. text-align: center;
  147. line-height: 200rpx;
  148. border: 2rpx solid #DDDDDD;
  149. }
  150. }
  151. }
  152. .submit_btn{
  153. color: #FFFFFF;
  154. width: 220rpx;
  155. height: 80rpx;
  156. display: block;
  157. font-size: 30rpx;
  158. padding: 0rpx 0rpx;
  159. line-height: 80rpx;
  160. margin: 50rpx auto;
  161. background-color: forestgreen;
  162. }
  163. }
  164. </style>