detail.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. // pages/ticketScan/detail.js
  2. const utils = require('../../utils/util.js')
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. belongEntTaxId: '',
  9. buyer: { //购方信息
  10. address: '',
  11. bankAccount: '',
  12. contactPhone: '',
  13. createBy: '',
  14. createTime: '',
  15. customerCode: '',
  16. customerId: '',
  17. customerMobile: '',
  18. customerName: '',
  19. email: '',
  20. entTaxId: '',
  21. lastUpdateBy: '',
  22. lastUpdateTime: '',
  23. manageUserId: '',
  24. parentCode: null,
  25. remark: null,
  26. shortCode: null
  27. },
  28. bankName: '', //开户行
  29. remark: '', //备注
  30. interactTypeDetail: '', //interactTypeDetail
  31. cardList: [{ //交付方式
  32. text: '邮箱',
  33. value: 1,
  34. selected: false
  35. },
  36. {
  37. text: '手机短信',
  38. value: 2,
  39. selected: false
  40. },
  41. {
  42. text: '微信卡包',
  43. value: 3,
  44. selected: true
  45. },
  46. {
  47. text: '支付宝发票管家',
  48. value: 3,
  49. selected: false
  50. },
  51. {
  52. text: '其他',
  53. value: 99,
  54. selected: false
  55. }
  56. ],
  57. },
  58. /**
  59. * 生命周期函数--监听页面加载
  60. */
  61. onLoad: function (options) {
  62. this.setData({
  63. belongEntTaxId: options.belongEntTaxId
  64. })
  65. },
  66. //提交开票
  67. submitData() {
  68. let buyer = this.data.buyer
  69. let params = {
  70. belongEntTaxId: this.data.belongEntTaxId,
  71. customerName: utils.trimAll(buyer.customerName),
  72. customerEntTaxId: utils.trimAll(buyer.entTaxId),
  73. address: utils.trimAll(buyer.address),
  74. contactPhone: utils.trimAll(buyer.contactPhone),
  75. bankName: utils.trimAll(this.data.bankName),
  76. bankAccountNo: utils.trimAll(buyer.bankAccount),
  77. customerEmail: utils.trimAll(buyer.email),
  78. customerMobile: utils.trimAll(buyer.customerMobile),
  79. remark: utils.trimAll(this.data.remark),
  80. interactType: '',
  81. interactTypeDetail: utils.trimAll(this.data.interactTypeDetail)
  82. }
  83. if (params.customerName === '') {
  84. utils.toast('发票抬头不能为空')
  85. return
  86. }
  87. if (params.customerEntTaxId === '') {
  88. utils.toast('税号不能为空')
  89. return
  90. }
  91. if (params.customerEmail === '') {
  92. utils.toast('邮箱不能为空')
  93. return
  94. }
  95. if (params.customerMobile === '') {
  96. utils.toast('手机号码不能为空')
  97. return
  98. }
  99. if (params.interactTypeDetail === '') {
  100. utils.toast('接收方式不能为空')
  101. return
  102. }
  103. let cardList = this.data.cardList
  104. for (let i = 0; i < cardList.length; i++) {
  105. if (cardList[i].selected) {
  106. params.interactType = cardList[i].value
  107. }
  108. }
  109. utils.axios({
  110. method: 'post',
  111. url: '/sys/taitou/todo/save',
  112. data: params,
  113. sendBefore() {
  114. wx.showLoading({
  115. title: '待开抬头保存中...',
  116. mask: true
  117. })
  118. },
  119. complete() {
  120. wx.hideLoading()
  121. },
  122. success: res => {
  123. wx.redirectTo({
  124. url: '/pages/ticketScan/success'
  125. })
  126. }
  127. })
  128. },
  129. //查询购方名字
  130. toSearch() {
  131. wx.navigateTo({
  132. url: '/pages/search/search'
  133. })
  134. },
  135. //选择接收方式
  136. selectType(e) {
  137. let index = Number(e.currentTarget.dataset.index)
  138. let cardList = this.data.cardList
  139. for (let i = 0; i < cardList.length; i++) {
  140. cardList[i].selected = false
  141. }
  142. cardList[index].selected = true
  143. this.setData({
  144. cardList
  145. })
  146. },
  147. //以下是获取表单信息的函数
  148. getcustomerName(e) {
  149. this.setData({
  150. ['buyer.customerName']: e.detail.value
  151. })
  152. },
  153. getentTaxId(e) {
  154. this.setData({
  155. ['buyer.entTaxId']: e.detail.value
  156. })
  157. },
  158. getemail(e) {
  159. this.setData({
  160. ['buyer.email']: e.detail.value
  161. })
  162. },
  163. getcustomerMobile(e) {
  164. this.setData({
  165. ['buyer.customerMobile']: e.detail.value
  166. })
  167. },
  168. getaddress(e) {
  169. this.setData({
  170. ['buyer.address']: e.detail.value
  171. })
  172. },
  173. getcontactPhone(e) {
  174. this.setData({
  175. ['buyer.contactPhone']: e.detail.value
  176. })
  177. },
  178. getbankName(e) {
  179. this.setData({
  180. bankName: e.detail.value
  181. })
  182. },
  183. getbankAccount(e) {
  184. this.setData({
  185. ['buyer.bankAccount']: e.detail.value
  186. })
  187. },
  188. getremark(e) {
  189. this.setData({
  190. remark: e.detail.value
  191. })
  192. },
  193. getinteractTypeDetail(e) {
  194. this.setData({
  195. interactTypeDetail: e.detail.value
  196. })
  197. },
  198. /**
  199. * 生命周期函数--监听页面初次渲染完成
  200. */
  201. onReady: function () {
  202. },
  203. /**
  204. * 生命周期函数--监听页面显示
  205. */
  206. onShow: function () {
  207. },
  208. /**
  209. * 生命周期函数--监听页面隐藏
  210. */
  211. onHide: function () {
  212. },
  213. /**
  214. * 生命周期函数--监听页面卸载
  215. */
  216. onUnload: function () {
  217. },
  218. /**
  219. * 页面相关事件处理函数--监听用户下拉动作
  220. */
  221. onPullDownRefresh: function () {
  222. },
  223. /**
  224. * 页面上拉触底事件的处理函数
  225. */
  226. onReachBottom: function () {
  227. },
  228. /**
  229. * 用户点击右上角分享
  230. */
  231. onShareAppMessage: function () {
  232. return {
  233. title: '诺信云',
  234. path: '/pages/index/index'
  235. }
  236. }
  237. })