apply.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. // lionfish_comshop/pages/supply/apply.js
  2. var util = require('../../utils/util.js');
  3. var app = getApp();
  4. var status = require('../../utils/index.js');
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. image_thumb: '',
  11. image_o_full: '',
  12. orign_image: '',
  13. shopname: '',
  14. name: '',
  15. mobile: '',
  16. product: ''
  17. },
  18. /**
  19. * 生命周期函数--监听页面加载
  20. */
  21. onLoad: function (options) {
  22. status.setNavBgColor();
  23. },
  24. /**
  25. * 生命周期函数--监听页面初次渲染完成
  26. */
  27. onReady: function () {
  28. },
  29. /**
  30. * 生命周期函数--监听页面显示
  31. */
  32. onShow: function () {
  33. },
  34. inputShopName: function (e) {
  35. this.setData({
  36. shopname: e.detail.value
  37. })
  38. },
  39. inputName: function (e) {
  40. this.setData({
  41. name: e.detail.value
  42. })
  43. },
  44. inputMobile: function (e) {
  45. this.setData({
  46. mobile: e.detail.value
  47. })
  48. },
  49. inputAdvantage: function (e) {
  50. this.setData({
  51. product: e.detail.value
  52. })
  53. },
  54. addImg: function () {
  55. var that = this;
  56. wx.chooseImage({
  57. count: 1,
  58. success: function (res) {
  59. var tempFilePaths = res.tempFilePaths;
  60. var new_thumb_img = that.data.thumb_img;
  61. wx.showLoading({ title: '上传中' });
  62. wx.uploadFile({
  63. url: app.util.url('entry/wxapp/index', {
  64. 'm': 'lionfish_comshop',
  65. 'controller': 'goods.doPageUpload'
  66. }),
  67. filePath: tempFilePaths[0],
  68. name: 'upfile',
  69. formData: {
  70. 'name': tempFilePaths[0]
  71. },
  72. header: {
  73. 'content-type': 'multipart/form-data'
  74. },
  75. success: function (res) {
  76. wx.hideLoading();
  77. var data = JSON.parse(res.data);
  78. var image_thumb = data.image_thumb;
  79. var image_o_full = data.image_o_full;
  80. var orign_image = data.image_o;
  81. that.setData({
  82. image_thumb: image_thumb,
  83. image_o_full: image_o_full,
  84. orign_image: orign_image
  85. })
  86. }
  87. })
  88. }
  89. });
  90. },
  91. submit: function () {
  92. var token = wx.getStorageSync('token');
  93. var shopname = this.data.shopname;
  94. var mobile = this.data.mobile;
  95. var name = this.data.name;
  96. var product = this.data.product;
  97. // var logo = this.data.orign_image;
  98. var that = this;
  99. if (shopname == '') {
  100. wx.showToast({
  101. title: '请填供应商名称',
  102. icon: 'none',
  103. })
  104. return false;
  105. }
  106. if (name == '') {
  107. wx.showToast({
  108. title: '请填写供应商联系人',
  109. icon: 'none',
  110. })
  111. return false;
  112. }
  113. if (mobile == '' || !(/^1(3|4|5|6|7|8|9)\d{9}$/.test(mobile))) {
  114. wx.showToast({
  115. title: '手机号码有误',
  116. icon: 'none',
  117. })
  118. return false;
  119. }
  120. var s_data = {
  121. shopname, name, mobile, product, controller: 'user.supply_apply', 'token': token
  122. };
  123. app.util.request({
  124. 'url': 'entry/wxapp/user',
  125. 'data': s_data,
  126. method: 'post',
  127. dataType: 'json',
  128. success: function (res) {
  129. if (res.data.code == 0) {
  130. wx.showToast({
  131. title: '提交成功,等待审核',
  132. icon: 'none',
  133. duration: 2000,
  134. success: function(){
  135. setTimeout(()=>{
  136. wx.switchTab({
  137. url: '/lionfish_comshop/pages/user/me',
  138. })
  139. }, 2000)
  140. }
  141. })
  142. } else {
  143. wx.showModal({
  144. title: '提示',
  145. content: res.data.msg,
  146. showCancel: false
  147. })
  148. }
  149. }
  150. })
  151. }
  152. })