brokerform.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <view>
  3. <form>
  4. <view class="cu-form-group margin-top">
  5. <view class="title"><text class="text-red text-bold padding-right-xs">*</text>姓名</view>
  6. <input placeholder="请输入姓名" data-val="title" @input="bindInput"></input>
  7. </view>
  8. <view class="cu-form-group">
  9. <view class="title"><text class="text-red text-bold padding-right-xs">*</text>手机号</view>
  10. <input placeholder="请输入手机号" data-val="mobile" @input="bindInput"></input>
  11. </view>
  12. <view class="cu-form-group">
  13. <view class="title"><text class="text-red text-bold padding-right-xs">*</text>代理门店</view>
  14. <picker mode="selector" @change="agentChange" :value="agentIndex" :range="agentArray" range-key="title">
  15. <view class="picker">
  16. {{agentArray[agentIndex].title}}
  17. </view>
  18. </picker>
  19. </view>
  20. <view class="cu-form-group">
  21. <view class="title"><text class="text-red text-bold padding-right-xs">*</text>镇街</view>
  22. <picker mode="multiSelector" @change="TownChange" @columnchange="TownColumnChange" :value="townIndex" :range="townArray">
  23. <view class="picker">
  24. {{townArray[0][townIndex[0]]}},{{townArray[1][townIndex[1]]}}
  25. </view>
  26. </picker>
  27. </view>
  28. <view class="cu-form-group">
  29. <view class="title"><text class="text-red text-bold padding-right-xs">*</text>区域</view>
  30. <input placeholder="请输入区域" data-val="region" @input="bindInput"></input>
  31. </view>
  32. <view class="cu-form-group">
  33. <view class="title"> <text class="text-red text-bold padding-right-xs">*</text> 工作地点</view>
  34. <view style="flex: 1; font-size: 30rpx; color: #AAAAAA; line-height: 100rpx;">
  35. <input placeholder="详细地址" disabled :value="address" v-if="address"></input>
  36. <button class="cu-btn bg-blue margin-tb-sm lg" style="width: 100%;" @tap="gpsmap()">地图选位置</button>
  37. </view>
  38. </view>
  39. <view class="padding flex flex-direction bg-white">
  40. <button class="cu-btn bg-blue margin-tb-sm lg" @tap="submit">立即提交</button>
  41. </view>
  42. <view class="bg-white padding-lr padding-bottom">申请经济人后等待后台审核</view>
  43. </form>
  44. </view>
  45. </template>
  46. <script>
  47. var _this;
  48. export default {
  49. data() {
  50. return {
  51. isRotate: false,
  52. address: '',
  53. userinfo: {},
  54. forminfo: {
  55. title: '',
  56. mobile: '',
  57. region: '',
  58. latitude: 0,
  59. longitude: 0,
  60. },
  61. agentArray: [],
  62. agentIndex: 0,
  63. townArray: [
  64. [],
  65. [],
  66. ],
  67. townIndex: [0,0],
  68. village: [],
  69. };
  70. },
  71. onLoad: function(){
  72. _this = this;
  73. _this.userinfo = _this.checkLogin("/pages/my/myinfo");
  74. //公司
  75. _this.$req.ajax({
  76. path: "index/getAgent",
  77. data: {}
  78. }).then((data) => {
  79. _this.agentArray = data;
  80. }).catch((err) => {
  81. uni.showModal({
  82. title: '信息提示',
  83. content: err,
  84. showCancel: false
  85. });
  86. });
  87. //镇街
  88. _this.$req.ajax({
  89. path: "index/getTown",
  90. data: {}
  91. }).then((data) => {
  92. _this.townArray = [data.town,data.village[0]];
  93. _this.village = data.village
  94. }).catch((err) => {
  95. uni.showModal({
  96. title: '信息提示',
  97. content: err,
  98. showCancel: false
  99. });
  100. });
  101. },
  102. methods: {
  103. bindInput(e) {
  104. var dataval = e.currentTarget.dataset.val;
  105. _this.forminfo[dataval] = e.detail.value;
  106. },
  107. agentChange(e) {
  108. this.agentIndex = e.detail.value
  109. },
  110. TownChange(e) {
  111. this.townIndex = e.detail.value
  112. },
  113. TownColumnChange(e) {
  114. let townIndex = _this.townIndex;
  115. //公司变更
  116. if (e.detail.column == 0) {
  117. _this.townArray[1] = _this.village[e.detail.value];
  118. _this.townIndex = [e.detail.value,0];
  119. _this.$forceUpdate();
  120. }
  121. //街道变更
  122. if (e.detail.column == 1) {
  123. townIndex[1] = e.detail.value;
  124. _this.townIndex = townIndex;
  125. _this.$forceUpdate();
  126. }
  127. },
  128. RegionChange(e) {
  129. this.region = e.detail.value
  130. },
  131. //打开地图
  132. gpsmap:function(){
  133. uni.chooseLocation({
  134. success: function (res) {
  135. _this.address=res.address;
  136. _this.forminfo.latitude=res.latitude;
  137. _this.forminfo.longitude=res.longitude;
  138. }
  139. });
  140. },
  141. submit() {
  142. if (_this.isRotate) {
  143. return false;
  144. }
  145. _this.isRotate = true;
  146. let data = _this.forminfo;
  147. let validate = {"title":"姓名","mobile":"手机号","region":"区域","latitude":"请点击地图选择位置"};
  148. for (var i in validate) {
  149. if (data[i] == "") {
  150. uni.showModal({
  151. title: '信息提示',
  152. content: validate[i]+"不能为空",
  153. showCancel: false
  154. });
  155. _this.isRotate = false;
  156. return false;
  157. }
  158. }
  159. data.userid = _this.userinfo.id;
  160. data.workerid = _this.agentArray[_this.agentIndex].workerid;
  161. data.agentid = _this.agentArray[_this.agentIndex].id;
  162. data.town = _this.townArray[0][_this.townIndex[0]];
  163. data.village = _this.townArray[1][_this.townIndex[1]];
  164. _this.$req.ajax({
  165. path: "broker/apply",
  166. data: data
  167. }).then((data) => {
  168. uni.showModal({
  169. title: '信息提示',
  170. content: '提交成功,等待管理员审核',
  171. showCancel: false,
  172. success: function() {
  173. uni.reLaunch({
  174. url: '/pages/index/index'
  175. });
  176. },
  177. });
  178. }).catch((err) => {
  179. uni.showModal({
  180. title: '信息提示',
  181. content: err,
  182. showCancel: false
  183. });
  184. _this.isRotate = false;
  185. });
  186. },
  187. }
  188. }
  189. </script>
  190. <style>
  191. .cu-form-group .title {
  192. min-width: calc(4em + 15px);
  193. }
  194. </style>