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.

266 lines
5.8 KiB

  1. var app = getApp();
  2. const config = require('../../../../config/config.js')
  3. const util = require('../../../../utils/util.js')
  4. const Http = require('../../../../utils/HttpBasics.js')
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. id: "",
  11. organizationType: '',
  12. picturesUrl: [],
  13. industryList: [],
  14. industryIndex: 0,
  15. qualification_id: "",
  16. settlement_id: "",
  17. qualification_type: "",
  18. message: "",
  19. flagImgUrl: false,
  20. },
  21. setIndustryIndexValue(e) {
  22. let value = e.detail.value
  23. console.log(this.data.industryList[value])
  24. this.setData({
  25. settlement_id: this.data.industryList[value].settlementId,
  26. qualification_id: this.data.industryList[value].code,
  27. qualification_type: this.data.industryList[value].name,
  28. flagImgUrl: this.data.industryList[value].flag,
  29. message: this.data.industryList[value].message,
  30. industryIndex: value,
  31. })
  32. },
  33. getQualification() {
  34. Http.get({
  35. url: config.api.getQualification,
  36. data: {
  37. organizationType: this.data.organizationType
  38. }
  39. }).then(res => {
  40. console.log(res.data)
  41. this.setData({
  42. industryList: res.data,
  43. qualification_id: res.data[0].code,
  44. settlement_id: res.data[0].settlementId,
  45. qualification_type: res.data[0].name,
  46. message: res.data[0].message
  47. })
  48. }).catch(err => {
  49. wx.hideLoading();
  50. wx.showToast({
  51. title: err.message,
  52. icon: "none",
  53. duration: 2000
  54. })
  55. })
  56. },
  57. getReceiverApply() {
  58. wx.showLoading({
  59. title: '加载中...',
  60. })
  61. Http.get({
  62. url: config.api.getReceiverApply,
  63. data: {
  64. merchantId: app.globalData.merchant.merchant_id
  65. }
  66. }).then(res => {
  67. if (res.data && res.data.organizationType) {
  68. this.setData({
  69. organizationType: res.data.organizationType
  70. })
  71. }
  72. if (res.data && res.data.id) {
  73. this.setData({
  74. id: res.data.id
  75. })
  76. }
  77. if (res.data && res.data.settlementInfo) {
  78. this.setData({
  79. qualification_id: JSON.parse(res.data.settlementInfo).qualification_id, //选择行业id
  80. settlement_id: JSON.parse(res.data.settlementInfo).settlement_id, //结算规则id
  81. qualification_type: JSON.parse(res.data.settlementInfo).qualification_type, //所属行业
  82. picturesUrl: JSON.parse(res.data.qualifications),
  83. industryIndex: JSON.parse(res.data.settlementInfo).industryIndex
  84. })
  85. }
  86. this.getQualification()
  87. wx.hideLoading();
  88. }).catch(err => {
  89. wx.hideLoading();
  90. wx.showToast({
  91. title: err.message,
  92. icon: "none",
  93. duration: 2000
  94. })
  95. })
  96. },
  97. upPictures() {
  98. let that = this;
  99. wx.chooseImage({
  100. success(res) {
  101. const tempFilePaths = res.tempFilePaths
  102. wx.uploadFile({
  103. url: config.api.merchantUpload, // 仅为示例,非真实的接口地址
  104. filePath: tempFilePaths[0],
  105. name: 'file',
  106. header: {
  107. 'token': app.globalData.token
  108. },
  109. success(res) {
  110. // let tempObj = that.data.businessLicenseInfo
  111. let tempUrl = ""
  112. let tempArr = that.data.picturesUrl
  113. tempArr.push(JSON.parse(res.data).data)
  114. console.log(tempArr)
  115. that.setData({
  116. picturesUrl: tempArr
  117. })
  118. }
  119. })
  120. }
  121. })
  122. },
  123. delPicturesUrl(e) {
  124. let tempArr = this.data.picturesUrl
  125. let index = e.currentTarget.dataset.index
  126. tempArr.splice(index, 1)
  127. this.setData({
  128. picturesUrl: tempArr,
  129. })
  130. },
  131. save(e) {
  132. let flag = e.currentTarget.dataset.flag
  133. let errMeg = "";
  134. let errFlag = false;
  135. if (this.data.flagImgUrl) {
  136. if (this.data.picturesUrl.length == 0) {
  137. errMeg = "请上传图片"
  138. errFlag = true
  139. }
  140. }
  141. if (errFlag) {
  142. wx.showToast({
  143. title: errMeg,
  144. icon: "none",
  145. duration: 2000
  146. })
  147. return
  148. }
  149. let settlementInfo = {
  150. qualification_id: this.data.qualification_id, //选择行业id
  151. settlement_id: this.data.settlement_id, //结算规则id
  152. qualification_type: this.data.qualification_type, //所属行业
  153. industryIndex: this.data.industryIndex
  154. }
  155. let parame = {};
  156. parame = {
  157. id: this.data.id,
  158. organizationType: this.data.organizationType,
  159. settlementInfo: JSON.stringify(settlementInfo),
  160. qualifications: JSON.stringify(this.data.picturesUrl)
  161. }
  162. console.log(parame, "parame")
  163. Http.post({
  164. url: config.api.receiverAdd,
  165. data: parame
  166. }).then(res => {
  167. console.log(res, "res")
  168. if (flag == "save") {
  169. wx.reLaunch({
  170. url: '/pages/warehouse/warehouse',
  171. })
  172. } else if (flag == "next") {
  173. wx.navigateTo({
  174. url: '/pages/warehouse/detail/clearingFirm/clearingFirm',
  175. })
  176. }
  177. }).catch(err => {
  178. wx.showToast({
  179. title: err.message,
  180. icon: "none",
  181. duration: 2000
  182. })
  183. })
  184. },
  185. /**
  186. * 生命周期函数--监听页面加载
  187. */
  188. onLoad: function(options) {
  189. this.getReceiverApply()
  190. },
  191. /**
  192. * 生命周期函数--监听页面初次渲染完成
  193. */
  194. onReady: function() {
  195. },
  196. /**
  197. * 生命周期函数--监听页面显示
  198. */
  199. onShow: function() {
  200. },
  201. /**
  202. * 生命周期函数--监听页面隐藏
  203. */
  204. onHide: function() {
  205. },
  206. /**
  207. * 生命周期函数--监听页面卸载
  208. */
  209. onUnload: function() {
  210. },
  211. /**
  212. * 页面相关事件处理函数--监听用户下拉动作
  213. */
  214. onPullDownRefresh: function() {
  215. },
  216. /**
  217. * 页面上拉触底事件的处理函数
  218. */
  219. onReachBottom: function() {
  220. },
  221. /**
  222. * 用户点击右上角分享
  223. */
  224. onShareAppMessage: function() {
  225. }
  226. })