index.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. const company = getApp().globalData.company
  2. let Parse = getApp().Parse;
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. status: 0,
  9. password: null,
  10. passwords: null,
  11. id: null,
  12. store: null,
  13. getText2: '获取验证码',
  14. loveChange: true,
  15. hongyzphone: '',
  16. // 验证码是否正确
  17. zhengLove: true,
  18. huoLove: '',
  19. },
  20. async getShopStore() {
  21. let ShopOrder = new Parse.Query('ShopStore')
  22. ShopOrder.notEqualTo('isDeleted', "true")
  23. ShopOrder.equalTo('company', company)
  24. ShopOrder.include('user')
  25. ShopOrder.equalTo('objectId', this.data.id)
  26. let shopOrder = await ShopOrder.first()
  27. if (shopOrder && shopOrder.id) {
  28. this.setData({
  29. store: shopOrder.toJSON()
  30. })
  31. console.log(this.data.store);
  32. }
  33. },
  34. yanLoveBtn: function () {
  35. let loveChange = this.data.loveChange;
  36. let phone = this.data.store.mobile;
  37. console.log(phone)
  38. let n = 59;
  39. let that = this;
  40. if (!phone) {
  41. wx.showToast({
  42. title: '手机号有误',
  43. icon: 'success',
  44. duration: 1000
  45. })
  46. } else {
  47. if (loveChange) {
  48. this.setData({
  49. loveChange: false
  50. })
  51. let lovetime = setInterval(function () {
  52. let str = '(' + n + ')' + '重新获取'
  53. that.setData({
  54. getText2: str
  55. })
  56. if (n <= 0) {
  57. that.setData({
  58. loveChange: true,
  59. getText2: '重新获取'
  60. })
  61. clearInterval(lovetime);
  62. }
  63. n--;
  64. }, 1000);
  65. console.log(phone)
  66. wx.request({
  67. url: "https://server.fmode.cn/api/apig/message",
  68. method: "post", //请求方式
  69. data: { mobile: phone, company: company, },
  70. success(res) {
  71. console.log(res)
  72. }
  73. })
  74. }
  75. }
  76. },
  77. formSubmit(e) {
  78. let that = this
  79. let val = e.detail.value
  80. console.log('val', val)
  81. var phone = this.data.store.mobile //电话
  82. var phoneCode = val.phoneCode //验证码
  83. var openid = wx.getStorageSync('userInfo').openid
  84. console.log(openid)
  85. wx.request({
  86. url: 'https://server.fmode.cn/api/apig/verifyCode',
  87. method: "post", //请求方式
  88. data: { mobile: phone, code: phoneCode, openid: openid },
  89. success(res) {
  90. console.log(res);
  91. if (res.data.code != 200) {
  92. wx.showToast({
  93. title: res.data.mess,
  94. icon: 'none'
  95. })
  96. return
  97. }
  98. that.setData({ status: 1 })
  99. }
  100. })
  101. console.log(this.data.status);
  102. },
  103. blur(e) {
  104. let name = e.currentTarget.dataset.name
  105. this.setData({
  106. [name]: e.detail.value
  107. })
  108. },
  109. async getuser() {
  110. if (this.data.password.length < 6) {
  111. wx.showToast({
  112. title: '密码长度不得小于6位数',
  113. icon: 'none'
  114. })
  115. return
  116. }
  117. if (this.data.password != this.data.passwords) {
  118. wx.showToast({
  119. title: '两次密码输入不同',
  120. icon: 'none'
  121. })
  122. return
  123. }
  124. let query = new Parse.Query("_User")
  125. console.log(this.data.store.user.objectId);
  126. let user = await query.get(this.data.store.user.objectId)
  127. user.set("password", this.data.password)
  128. user.save().then(res => {
  129. console.log(res)
  130. wx.showToast({
  131. title: '重置成功',
  132. icon: 'none'
  133. })
  134. wx.navigateBack({
  135. delta: 1
  136. });
  137. })
  138. },
  139. yanLoveInput: function (e) {
  140. let that = this;
  141. let yanLove = e.detail.value;
  142. let huoLove = this.data.huoLove;
  143. that.setData({
  144. yanLove: yanLove,
  145. zhengLove: false,
  146. })
  147. if (yanLove.length >= 7) {
  148. if (yanLove == huoLove) {
  149. that.setData({
  150. zhengLove: true,
  151. })
  152. } else {
  153. that.setData({
  154. zhengLove: false,
  155. })
  156. wx.showModal({
  157. content: '输入验证码有误',
  158. showCancel: false,
  159. success: function (res) { }
  160. })
  161. }
  162. }
  163. },
  164. /**
  165. * 生命周期函数--监听页面加载
  166. */
  167. onLoad: function (options) {
  168. let id = options.id
  169. this.setData({ id: id })
  170. this.getShopStore()
  171. },
  172. /**
  173. * 生命周期函数--监听页面初次渲染完成
  174. */
  175. onReady: function () {
  176. },
  177. /**
  178. * 生命周期函数--监听页面显示
  179. */
  180. onShow: function () {
  181. },
  182. /**
  183. * 生命周期函数--监听页面隐藏
  184. */
  185. onHide: function () {
  186. },
  187. /**
  188. * 生命周期函数--监听页面卸载
  189. */
  190. onUnload: function () {
  191. },
  192. /**
  193. * 页面相关事件处理函数--监听用户下拉动作
  194. */
  195. onPullDownRefresh: function () {
  196. },
  197. /**
  198. * 页面上拉触底事件的处理函数
  199. */
  200. onReachBottom: function () {
  201. },
  202. /**
  203. * 用户点击右上角分享
  204. */
  205. onShareAppMessage: function () {
  206. }
  207. })