brokerform.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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="multiSelector" @change="MultiChange" @columnchange="MultiColumnChange" :value="multiIndex" :range="multiArray" range-key="title">
  15. <view class="picker">
  16. {{multiArray[0][multiIndex[0]].title}},{{multiArray[1][multiIndex[1]].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. </form>
  36. </view>
  37. </template>
  38. <script>
  39. var _this;
  40. export default {
  41. data() {
  42. return {
  43. isRotate: false,
  44. userinfo: {},
  45. forminfo: {
  46. title: '',
  47. mobile: '',
  48. region: '',
  49. },
  50. multiArray: [
  51. [],
  52. [],
  53. ],
  54. multiIndex: [0, 0],
  55. townArray: [
  56. [],
  57. [],
  58. ],
  59. townIndex: [0,0],
  60. village: [],
  61. };
  62. },
  63. onLoad: function(){
  64. _this = this;
  65. _this.userinfo = _this.checkLogin("/pages/my/myinfo");
  66. //公司
  67. _this.$req.ajax({
  68. path: "index/getWorker",
  69. data: {}
  70. }).then((data) => {
  71. _this.multiArray = data;
  72. }).catch((err) => {
  73. uni.showModal({
  74. title: '信息提示',
  75. content: err,
  76. showCancel: false
  77. });
  78. });
  79. //镇街
  80. _this.$req.ajax({
  81. path: "index/getTown",
  82. data: {}
  83. }).then((data) => {
  84. _this.townArray = [data.town,data.village[0]];
  85. _this.village = data.village
  86. }).catch((err) => {
  87. uni.showModal({
  88. title: '信息提示',
  89. content: err,
  90. showCancel: false
  91. });
  92. });
  93. },
  94. methods: {
  95. bindInput(e) {
  96. var dataval = e.currentTarget.dataset.val;
  97. _this.forminfo[dataval] = e.detail.value;
  98. },
  99. MultiChange(e) {
  100. this.multiIndex = e.detail.value
  101. },
  102. TownChange(e) {
  103. this.townIndex = e.detail.value
  104. },
  105. MultiColumnChange(e) {
  106. let multi = _this.multiIndex;
  107. //公司变更
  108. if (e.detail.column == 0) {
  109. let workerid = _this.multiArray[0][e.detail.value].id;
  110. _this.$req.ajax({
  111. path: "index/getAgentByWorker",
  112. data: {workerid:workerid}
  113. }).then((data) => {
  114. let multiArray = _this.multiArray;
  115. multiArray[1] = data;
  116. _this.multiArray = multiArray;
  117. multi = [e.detail.value,0];
  118. _this.multiIndex = multi;
  119. _this.$forceUpdate();
  120. }).catch((err) => {
  121. uni.showModal({
  122. title: '信息提示',
  123. content: err,
  124. showCancel: false
  125. });
  126. });
  127. }
  128. //门店变更
  129. if (e.detail.column == 1) {
  130. multi[1] = e.detail.value;
  131. _this.multiIndex = multi;
  132. _this.$forceUpdate();
  133. }
  134. },
  135. TownColumnChange(e) {
  136. let townIndex = _this.townIndex;
  137. //公司变更
  138. if (e.detail.column == 0) {
  139. _this.townArray[1] = _this.village[e.detail.value];
  140. _this.townIndex = [e.detail.value,0];
  141. _this.$forceUpdate();
  142. }
  143. //街道变更
  144. if (e.detail.column == 1) {
  145. townIndex[1] = e.detail.value;
  146. _this.townIndex = townIndex;
  147. _this.$forceUpdate();
  148. }
  149. },
  150. RegionChange(e) {
  151. this.region = e.detail.value
  152. },
  153. submit() {
  154. if (_this.isRotate) {
  155. return false;
  156. }
  157. _this.isRotate = true;
  158. let data = _this.forminfo;
  159. console.log(data,22);
  160. let validate = {"title":"姓名","mobile":"手机号","region":"区域"};
  161. for (var i in validate) {
  162. if (data[i] == "") {
  163. uni.showModal({
  164. title: '信息提示',
  165. content: validate[i]+"不能为空",
  166. showCancel: false
  167. });
  168. _this.isRotate = false;
  169. return false;
  170. }
  171. }
  172. data.userid = _this.userinfo.id;
  173. data.workerid = _this.multiArray[0][_this.multiIndex[0]].id;
  174. data.agentid = _this.multiArray[1][_this.multiIndex[1]].id;
  175. data.town = _this.townArray[0][_this.townIndex[0]];
  176. data.village = _this.townArray[1][_this.townIndex[1]];
  177. _this.$req.ajax({
  178. path: "broker/apply",
  179. data: data
  180. }).then((data) => {
  181. uni.showModal({
  182. title: '信息提示',
  183. content: '提交成功,等待管理员审核',
  184. showCancel: false,
  185. success: function() {
  186. uni.reLaunch({
  187. url: '/pages/index/index'
  188. });
  189. },
  190. });
  191. }).catch((err) => {
  192. uni.showModal({
  193. title: '信息提示',
  194. content: err,
  195. showCancel: false
  196. });
  197. _this.isRotate = false;
  198. });
  199. },
  200. }
  201. }
  202. </script>
  203. <style>
  204. .cu-form-group .title {
  205. min-width: calc(4em + 15px);
  206. }
  207. </style>