index.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. const util = require('../../../utils/util.js');
  2. const app = getApp();
  3. Page({
  4. data: {
  5. picture: '',
  6. showQrcode: false,
  7. showCode: false,
  8. checkRadio: 1
  9. },
  10. onLoad: function (options) {
  11. console.log(options);
  12. if (options.flag == 1) {
  13. this.setData({
  14. checkRadio: 1
  15. })
  16. }
  17. if (!util.isObjEmpty(options) && options.type == 'share' && util.isObjEmpty(app.globalData.userInfo)) {
  18. wx.navigateTo({
  19. url: '/pages/home/login'
  20. });
  21. }
  22. },
  23. onReady: function () {
  24. },
  25. onShow: function () {
  26. },
  27. // 单选框
  28. radioChange(e) {
  29. console.log(e)
  30. let value = e.detail.value;
  31. this.setData({ checkRadio: value })
  32. },
  33. // 选择图片
  34. selectPic() {
  35. let that = this;
  36. if (util.isObjEmpty(app.globalData.userInfo)) {
  37. // wx.showModal({
  38. // content: '您还未登录,请先前往登录。',
  39. // confirmText:'立即前往',
  40. // showCancel:false,
  41. // success (res) {
  42. // if (res.confirm) {
  43. // wx.navigateTo({
  44. // url: '/pages/home/login'
  45. // });
  46. // }
  47. // }
  48. // })
  49. // 静默登录
  50. let that = this
  51. util.silentLogin().then(resr => {
  52. wx.chooseImage({
  53. sizeType: ['original', 'compressed'],
  54. count: 1,
  55. sourceType: ['album', 'camera'],
  56. success(res) {
  57. wx.showLoading({ title: '上传中…' });
  58. that.uploadAli(res.tempFilePaths[0]);
  59. }
  60. })
  61. })
  62. return false;
  63. }
  64. wx.chooseImage({
  65. sizeType: ['original', 'compressed'],
  66. count: 1,
  67. sourceType: ['album', 'camera'],
  68. success(res) {
  69. wx.showLoading({ title: '上传中…' });
  70. that.uploadAli(res.tempFilePaths[0]);
  71. }
  72. })
  73. },
  74. // 图片上传
  75. uploadAli(img) {
  76. var that = this;
  77. wx.uploadFile({
  78. url: util.config.apiServer + 'user/upload_img_app.do',
  79. filePath: img,
  80. name: 'avatarFile',
  81. formData: {
  82. "rid": app.globalData.userInfo['rid']
  83. },
  84. success: function (res) {
  85. let datas = JSON.parse(res.data);
  86. if (res.statusCode == 200 && datas.code == 0) {
  87. that.setData({ picture: datas.data.image })
  88. }
  89. wx.hideLoading();
  90. }
  91. })
  92. },
  93. // 删除图片
  94. deletPic() {
  95. this.setData({ picture: '' })
  96. },
  97. // 联系客服
  98. connect() {
  99. this.setData({ showQrcode: true })
  100. },
  101. // 提交
  102. submit() {
  103. util.requestMsg('9N_BQYOCniXrjVJ52O9AvbNHs2T078uIcR1iAJI7ql0').then(e => {
  104. this.sub()
  105. }).catch(res => {
  106. this.sub()
  107. })
  108. },
  109. sub() {
  110. let that = this;
  111. if (!util.isEmpty(this.data.picture)) {
  112. util.ajax({
  113. func: 'v2/user/apply/save',
  114. data: {
  115. content: this.data.picture,
  116. type: this.data.checkRadio
  117. },
  118. method: "POST",
  119. }, function (res) {
  120. if (res.code == 0) {
  121. // that.setData({showCode:true})
  122. wx.showModal({
  123. content: '上传成功!请耐心等待工作人员审核。',
  124. showCancel: false,
  125. success(res) {
  126. if (res.confirm) {
  127. that.setData({ picture: '' })
  128. }
  129. }
  130. })
  131. } else {
  132. util.showTips(res.reason);
  133. }
  134. })
  135. } else {
  136. util.showTips('请上传图片!');
  137. }
  138. },
  139. closeTip(e) {
  140. let data = e.detail;
  141. switch (data.type) {
  142. case "contact":
  143. this.setData({ showQrcode: data.status })
  144. break;
  145. case "subSuccess":
  146. this.setData({ showCode: data.status })
  147. break;
  148. }
  149. },
  150. // 用户点击右上角分享
  151. onShareAppMessage: function () {
  152. return {
  153. title: '上传发圈截图,领取更多优惠福利。',
  154. path: '/pages/turntable/hairpin/index?type=share',
  155. imageUrl: 'https://img.bbztx.com/image_test/upload/thumbs/20220905/logo/1662359120902091698.png'
  156. // http://img.bbztx.com/image_test/upload/thumbs/20211028/logo/1635393155723077256.jpg
  157. // http://img.bbztx.com/image_test/upload/thumbs/20210326/logo/1616725535699049709.jpg
  158. }
  159. },
  160. })