info.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. if( !this.requestParam.province ){
  54. uni.showToast({
  55. title:"请选择所在城市",
  56. icon:"none"
  57. })
  58. return ;
  59. }
  60. // 提示信息
  61. if( !this.requestParam.city ){
  62. uni.showToast({
  63. title:"请选择所在城市",
  64. icon:"none"
  65. })
  66. return ;
  67. }
  68. // 请求状态
  69. uni.showLoading({mask:true});
  70. // 授权成功以后,调用绑定
  71. this.$http.request('api/custom/set_city',this.requestParam,'post').then((re)=>{
  72. // 关闭
  73. uni.hideLoading();
  74. // 成功的话
  75. if( re.code != 'success' ){
  76. // 跳转
  77. uni.showToast({title: re.msg,icon:"none"});
  78. return;
  79. }
  80. uni.switchTab({url: '/pages/user/index'});
  81. });
  82. },
  83. cityChange(e){
  84. // 替换三个选项
  85. this.cityValue.splice(e.detail.column,1,e.detail.value);
  86. // 下一级设置为0
  87. if( e.detail.column == 0 ){
  88. this.cityValue.splice(1,1,0);
  89. this.cityValue.splice(2,1,0);
  90. }
  91. if( e.detail.column == 1 ){
  92. this.cityValue.splice(2,1,0);
  93. }
  94. // 替换对应的数据
  95. this.cityArray.splice(0,1,getProvinces());
  96. this.cityArray.splice(1,1,getMyCity(this.cityValue[0]));
  97. },
  98. cityFinish(e){
  99. this.requestParam.province = this.cityArray[0][this.cityValue[0]];
  100. this.requestParam.city = this.cityArray[1][this.cityValue[1]];
  101. },
  102. }
  103. }
  104. </script>
  105. <style lang="less">
  106. .alter_info{
  107. display: block;
  108. color: #E03519;
  109. font-size: 20rpx;
  110. overflow: hidden;
  111. margin: 20rpx auto;
  112. background: #FFFFFF;
  113. line-height: 40rpx;
  114. padding: 35rpx 35rpx;
  115. text-align: center;
  116. }
  117. .info_form{
  118. display: block;
  119. overflow: hidden;
  120. padding: 20rpx 0rpx;
  121. background: #FFFFFF;
  122. .form_group{
  123. display: block;
  124. overflow: hidden;
  125. line-height: 60rpx;
  126. padding: 20rpx 35rpx;
  127. .group_title{
  128. float: left;
  129. width: 160rpx;
  130. display: block;
  131. overflow: hidden;
  132. font-size: 30rpx;
  133. margin-right: 20rpx;
  134. }
  135. .group_box{
  136. width: 480rpx;
  137. float: left;
  138. display: block;
  139. .form_ctrl{
  140. height: 56rpx;
  141. font-size: 24rpx;
  142. padding: 0rpx 20rpx;
  143. line-height: 56rpx;;
  144. border: 2rpx solid #DDDDDD;
  145. .area_text{
  146. width: 446rpx;
  147. height: 56rpx;
  148. font-size: 20rpx;
  149. overflow: hidden;
  150. white-space: nowrap;
  151. line-height: 56rpx;
  152. text-overflow: ellipsis;
  153. }
  154. }
  155. .group_image{
  156. width: 200rpx;
  157. height: 200rpx;
  158. }
  159. .choose_image{
  160. display: block;
  161. width: 200rpx;
  162. height: 200rpx;
  163. font-size: 38rpx;
  164. text-align: center;
  165. line-height: 200rpx;
  166. border: 2rpx solid #DDDDDD;
  167. }
  168. }
  169. }
  170. .submit_btn{
  171. color: #FFFFFF;
  172. width: 220rpx;
  173. height: 80rpx;
  174. display: block;
  175. font-size: 30rpx;
  176. padding: 0rpx 0rpx;
  177. line-height: 80rpx;
  178. margin: 50rpx auto;
  179. background-color: forestgreen;
  180. }
  181. }
  182. </style>