brokerform.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <view>
  3. <form>
  4. <view class="cu-form-group margin-top">
  5. <view class="title">姓名</view>
  6. <input placeholder="请输入姓名" data-val="title" @input="bindInput"></input>
  7. </view>
  8. <view class="cu-form-group">
  9. <view class="title">手机号</view>
  10. <input placeholder="请输入手机号" data-val="mobile" @input="bindInput"></input>
  11. </view>
  12. <view class="cu-form-group">
  13. <view class="title">代理门店</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">镇街</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">区域</view>
  30. <input placeholder="请输入区域" data-val="region" @input="bindInput"></input>
  31. </view>
  32. <view class="padding flex flex-direction bg-white">
  33. <button class="cu-btn bg-blue margin-tb-sm lg" @tap="submit">立即提交</button>
  34. </view>
  35. <view class="bg-white padding-lr padding-bottom">申请经济人后等待后台审核</view>
  36. </form>
  37. </view>
  38. </template>
  39. <script>
  40. var _this;
  41. export default {
  42. data() {
  43. return {
  44. isRotate: false,
  45. userinfo: {},
  46. forminfo: {
  47. title: '',
  48. mobile: '',
  49. region: '',
  50. },
  51. agentArray: [],
  52. agentIndex: 0,
  53. townArray: [
  54. [],
  55. [],
  56. ],
  57. townIndex: [0,0],
  58. village: [],
  59. };
  60. },
  61. onLoad: function(){
  62. _this = this;
  63. _this.userinfo = _this.checkLogin("/pages/my/myinfo");
  64. //公司
  65. _this.$req.ajax({
  66. path: "index/getAgent",
  67. data: {}
  68. }).then((data) => {
  69. _this.agentArray = data;
  70. }).catch((err) => {
  71. uni.showModal({
  72. title: '信息提示',
  73. content: err,
  74. showCancel: false
  75. });
  76. });
  77. //镇街
  78. _this.$req.ajax({
  79. path: "index/getTown",
  80. data: {}
  81. }).then((data) => {
  82. _this.townArray = [data.town,data.village[0]];
  83. _this.village = data.village
  84. }).catch((err) => {
  85. uni.showModal({
  86. title: '信息提示',
  87. content: err,
  88. showCancel: false
  89. });
  90. });
  91. },
  92. methods: {
  93. bindInput(e) {
  94. var dataval = e.currentTarget.dataset.val;
  95. _this.forminfo[dataval] = e.detail.value;
  96. },
  97. agentChange(e) {
  98. this.agentIndex = e.detail.value
  99. },
  100. TownChange(e) {
  101. this.townIndex = e.detail.value
  102. },
  103. TownColumnChange(e) {
  104. let townIndex = _this.townIndex;
  105. //公司变更
  106. if (e.detail.column == 0) {
  107. _this.townArray[1] = _this.village[e.detail.value];
  108. _this.townIndex = [e.detail.value,0];
  109. _this.$forceUpdate();
  110. }
  111. //街道变更
  112. if (e.detail.column == 1) {
  113. townIndex[1] = e.detail.value;
  114. _this.townIndex = townIndex;
  115. _this.$forceUpdate();
  116. }
  117. },
  118. RegionChange(e) {
  119. this.region = e.detail.value
  120. },
  121. submit() {
  122. if (_this.isRotate) {
  123. return false;
  124. }
  125. _this.isRotate = true;
  126. let data = _this.forminfo;
  127. let validate = {"title":"姓名","mobile":"手机号","region":"区域"};
  128. for (var i in validate) {
  129. if (data[i] == "") {
  130. uni.showModal({
  131. title: '信息提示',
  132. content: validate[i]+"不能为空",
  133. showCancel: false
  134. });
  135. _this.isRotate = false;
  136. return false;
  137. }
  138. }
  139. data.userid = _this.userinfo.id;
  140. data.workerid = _this.agentArray[_this.agentIndex].workerid;
  141. data.agentid = _this.agentArray[_this.agentIndex].id;
  142. data.town = _this.townArray[0][_this.townIndex[0]];
  143. data.village = _this.townArray[1][_this.townIndex[1]];
  144. _this.$req.ajax({
  145. path: "broker/apply",
  146. data: data
  147. }).then((data) => {
  148. uni.showModal({
  149. title: '信息提示',
  150. content: '提交成功,等待管理员审核',
  151. showCancel: false,
  152. success: function() {
  153. uni.reLaunch({
  154. url: '/pages/index/index'
  155. });
  156. },
  157. });
  158. }).catch((err) => {
  159. uni.showModal({
  160. title: '信息提示',
  161. content: err,
  162. showCancel: false
  163. });
  164. _this.isRotate = false;
  165. });
  166. },
  167. }
  168. }
  169. </script>
  170. <style>
  171. .cu-form-group .title {
  172. min-width: calc(4em + 15px);
  173. }
  174. </style>