style.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. // pages/style/style.js
  2. const $api = require('../../utils/api.js').API;
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. arr1: ['短线', '中线', '长线'],
  9. arr2: ['分仓', '重仓', '全仓', '融资'],
  10. arr3: ['首板', '接力', '半路', '低吸', '价值投机', '波段锁仓', '可转债'],
  11. arr4: ['5厘米', '10厘米', '20厘米', '次新股','N字头','可转债'],
  12. form:{
  13. join_time: '',
  14. zq: '',
  15. cw: '',
  16. df: '',
  17. init_fund: '',
  18. account_img: ''
  19. }
  20. },
  21. /**
  22. * 生命周期函数--监听页面加载
  23. */
  24. onLoad: function (options) {
  25. $api.getEnumList().then(res => {
  26. this.setData({
  27. arr1: res.data.data.zq,
  28. arr2: res.data.data.cw,
  29. arr3: res.data.data.df,
  30. arr4: res.data.data.pz
  31. })
  32. })
  33. $api.getMyStyle().then(res=>{
  34. this.setData({
  35. form:res.data.data
  36. })
  37. })
  38. },
  39. change(e){
  40. let value = e.target.dataset.id, item = e.target.dataset.item;
  41. let form=this.data.form;
  42. form[item] = value;
  43. this.setData({
  44. form: form
  45. })
  46. },
  47. bindDateChange(e) {
  48. let form = this.data.form;
  49. form.join_time = e.detail.value;
  50. this.setData({
  51. form: form
  52. })
  53. },
  54. bindinput(e){
  55. let form = this.data.form;
  56. form.init_fund = e.detail.value;
  57. this.setData({
  58. form: form
  59. })
  60. },
  61. uploadImg(){
  62. var form = this.data.form;
  63. wx.chooseImage({
  64. success: res => {
  65. wx.showLoading({
  66. title: '正在上传',
  67. })
  68. const tempFilePaths = res.tempFiles
  69. for (let i = 0; i < tempFilePaths.length; i++) {
  70. $api.upload(tempFilePaths[i].path,'file').then(res=>{
  71. wx.hideLoading()
  72. if(res.code == 0){
  73. form.account_img=res.data.url;
  74. this.setData({
  75. form: form
  76. })
  77. }else{
  78. wx.showToast({
  79. title: '上传失败',
  80. })
  81. }
  82. })
  83. .catch(err=>{
  84. wx.hideLoading()
  85. })
  86. }
  87. }
  88. })
  89. },
  90. preview(){
  91. wx.previewImage({
  92. urls: [this.data.form.account_img],
  93. current: this.data.form.account_img
  94. })
  95. },
  96. del(){
  97. let form = this.data.form;
  98. form.account_img ='';
  99. this.setData({
  100. form: form
  101. })
  102. },
  103. post(){
  104. var form=this.data.form;
  105. if (!form.join_time){
  106. wx.showToast({
  107. title: '请选择入市时间',
  108. })
  109. return
  110. }
  111. if (!form.init_fund) {
  112. wx.showToast({
  113. title: '请输入参赛金额',
  114. })
  115. return
  116. }
  117. if (!form.account_img) {
  118. wx.showToast({
  119. title: '请上传账号截图',
  120. })
  121. return
  122. }
  123. wx.showLoading({
  124. title: '正在提交',
  125. })
  126. $api.updateStyle(form).then(res=>{
  127. wx.hideLoading()
  128. wx.showToast({
  129. title: '保存成功',
  130. icon:'success'
  131. })
  132. })
  133. .catch(err=>{
  134. wx.hideLoading()
  135. })
  136. },
  137. /**
  138. * 生命周期函数--监听页面初次渲染完成
  139. */
  140. onReady: function () {
  141. },
  142. /**
  143. * 生命周期函数--监听页面显示
  144. */
  145. onShow: function () {
  146. },
  147. /**
  148. * 生命周期函数--监听页面隐藏
  149. */
  150. onHide: function () {
  151. },
  152. /**
  153. * 生命周期函数--监听页面卸载
  154. */
  155. onUnload: function () {
  156. },
  157. /**
  158. * 页面相关事件处理函数--监听用户下拉动作
  159. */
  160. onPullDownRefresh: function () {
  161. },
  162. /**
  163. * 页面上拉触底事件的处理函数
  164. */
  165. onReachBottom: function () {
  166. },
  167. /**
  168. * 用户点击右上角分享
  169. */
  170. onShareAppMessage: function () {
  171. }
  172. })