C端小程序
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

167 rindas
2.9 KiB

  1. let app = getApp();
  2. const Http = require("../../utils/HttpBasics");
  3. const bgColor = require("../../utils/bgColor.js")
  4. const config = require("../../config/config");
  5. const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px'
  6. const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. navigationBarHeight,
  13. avatarUrl: defaultAvatarUrl,
  14. nickName: '',
  15. theme: wx.getSystemInfoSync().theme,
  16. typeLsit: {},
  17. },
  18. /**
  19. * 获取全局样式
  20. */
  21. getType() {
  22. Http.get({
  23. url: config.api.setType,
  24. data: {
  25. mouldType: app.globalData.mouldType
  26. }
  27. }).then(res => {
  28. const {
  29. code,
  30. data
  31. } = res
  32. if (code == 200) {
  33. app.globalData.typeLsit = data
  34. this.setData({
  35. typeLsit: data,
  36. })
  37. }
  38. })
  39. },
  40. getNickName(e) {
  41. },
  42. formSubmit(e) {
  43. const data = {
  44. avatarUrl: this.data.avatarUrl,
  45. nickName: e.detail.value.nickname
  46. }
  47. if (data.nickName) {
  48. Http.post({
  49. url: "/user/updateUserInfo",
  50. data,
  51. }).then(res => {
  52. if (res.code == 200) {
  53. wx.showToast({
  54. title: '更改成功',
  55. icon: 'success',
  56. duration: 2000
  57. })
  58. setTimeout(() => {
  59. wx.navigateBack()
  60. }, 2000)
  61. }
  62. }).catch(err => {
  63. console.log(err);
  64. })
  65. } else {
  66. wx.showToast({
  67. title: '请输入昵称',
  68. icon: 'error',
  69. duration: 2000
  70. })
  71. }
  72. },
  73. getUserInfo(token) {
  74. let that = this;
  75. Http.get({
  76. url: config.api.getScore,
  77. data: {
  78. token: token
  79. }
  80. }).then(res => {
  81. console.log(res, 'res');
  82. this.setData({
  83. avatarUrl: res.data.avatarUrl,
  84. nickName: res.data.nickName
  85. })
  86. }).catch(err => {
  87. console.log(err, 'err');
  88. })
  89. },
  90. /**
  91. * 生命周期函数--监听页面加载
  92. */
  93. onLoad(options) {
  94. if (app.globalData.token) {
  95. this.getUserInfo(app.globalData.token)
  96. }
  97. this.getType(),
  98. wx.onThemeChange((result) => {
  99. this.setData({
  100. theme: result.theme
  101. })
  102. })
  103. },
  104. /**
  105. * 生命周期函数--监听页面初次渲染完成
  106. */
  107. onReady() {
  108. },
  109. /**
  110. * 生命周期函数--监听页面显示
  111. */
  112. onShow() {
  113. },
  114. /**
  115. * 生命周期函数--监听页面隐藏
  116. */
  117. onHide() {
  118. },
  119. /**
  120. * 生命周期函数--监听页面卸载
  121. */
  122. onUnload() {
  123. },
  124. /**
  125. * 页面相关事件处理函数--监听用户下拉动作
  126. */
  127. onPullDownRefresh() {
  128. },
  129. /**
  130. * 页面上拉触底事件的处理函数
  131. */
  132. onReachBottom() {
  133. },
  134. /**
  135. * 用户点击右上角分享
  136. */
  137. onShareAppMessage() {
  138. },
  139. onChooseAvatar(e) {
  140. const { avatarUrl } = e.detail
  141. this.setData({
  142. avatarUrl,
  143. })
  144. },
  145. })