金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

177 lines
4.3 KiB

  1. <template>
  2. <view id="distribution">
  3. <view class="distribution">
  4. <view class="distributeconent">
  5. <view class="cardInfo selectName">
  6. <input type="text" placeholder="请输入姓名" @input="getName"></input>
  7. </view>
  8. <view class="cardInfo selectPhone">
  9. <input type="text" placeholder="请输入手机号码" @input="getPhone"></input>
  10. </view>
  11. <view class="cardInfo selectOther">
  12. <input type="text" placeholder="备注" @input="getInfo"></input>
  13. </view>
  14. </view>
  15. <view class="saveCard">
  16. <button :style="'background: ' + config.mainColor" @tap="checkValue">提交申请</button>
  17. </view>
  18. </view>
  19. <view class="home" @tap="jumpHome" :style="'background: ' + config.mainColor">
  20. <i class="iconfont icon--shouye"></i>
  21. <view>
  22. 首页
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import {pageLogin, getUrl,config,is} from '@/common/js/utils.js';
  29. export default {
  30. data() {
  31. return {
  32. name: '',
  33. phone: '',
  34. info: '',
  35. message: '',
  36. config: ''
  37. };
  38. },
  39. onLoad() {
  40. // 第三方平台配置颜色
  41. var bgConfig = this.$cookieStorage.get('globalConfig') || '';
  42. this.setData({
  43. config: bgConfig
  44. });
  45. },
  46. components: {},
  47. props: {},
  48. methods: {
  49. getName(e) {
  50. this.setData({
  51. name: e.detail.value
  52. });
  53. },
  54. getPhone(e) {
  55. this.setData({
  56. phone: e.detail.value
  57. });
  58. },
  59. getInfo(e) {
  60. this.setData({
  61. info: e.detail.value
  62. });
  63. },
  64. jumpHome() {
  65. wx.switchTab({
  66. url: '/pages/index/index/index'
  67. });
  68. },
  69. checkValue(e) {
  70. var token = this.$cookieStorage.get('user_token'); //获取用户的token
  71. var message = '';
  72. if (!this.name) {
  73. message = '请输入您的姓名';
  74. } else if (!this.phone) {
  75. message = '请输入您的手机号码';
  76. } else if (this.phone != "" && !is.mobile(this.phone)) {
  77. message = '手机号码格式不正确';
  78. }
  79. if (message) {
  80. wx.showModal({
  81. content: message,
  82. showCancel: false
  83. });
  84. return;
  85. } else {
  86. wx.showLoading({
  87. title: '加载中',
  88. mask: true
  89. });
  90. this.$http.post({
  91. api: 'api/distribution/register',
  92. header: {
  93. Authorization: token
  94. },
  95. data: {
  96. name: this.name,
  97. mobile: this.phone,
  98. note: this.info
  99. }
  100. }).then(res => {
  101. if (res.statusCode == 200) {
  102. res = res.data;
  103. if (res.status) {
  104. wx.showModal({
  105. content: res.message,
  106. showCancel: false,
  107. success: res => {
  108. if (res.confirm || !res.cancel && !res.confirm) {
  109. wx.switchTab({
  110. url: '/pages/user/personal/personal'
  111. });
  112. }
  113. }
  114. });
  115. } else {
  116. wx.showModal({
  117. content: res.message || '请求失败',
  118. showCancel: false
  119. });
  120. }
  121. } else {
  122. wx.showModal({
  123. content: '请求失败,请稍后重试',
  124. showCancel: false
  125. });
  126. }
  127. wx.hideLoading();
  128. }).catch(rej => {
  129. wx.showModal({
  130. content: '请求失败,请稍后重试',
  131. showCancel: false
  132. });
  133. wx.hideLoading();
  134. });
  135. }
  136. },
  137. setData: function (obj) {
  138. let that = this;
  139. let keys = [];
  140. let val, data;
  141. Object.keys(obj).forEach(function (key) {
  142. keys = key.split('.');
  143. val = obj[key];
  144. data = that.$data;
  145. keys.forEach(function (key2, index) {
  146. if (index + 1 == keys.length) {
  147. that.$set(data, key2, val);
  148. } else {
  149. if (!data[key2]) {
  150. that.$set(data, key2, {});
  151. }
  152. }
  153. data = data[key2];
  154. });
  155. });
  156. }
  157. },
  158. computed: {},
  159. watch: {}
  160. };
  161. </script>
  162. <style rel="stylesheet/less" lang="less">
  163. @import "applyDistribution";
  164. </style>