经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 移动开发 » 微信小程序 » 查看文章
小程序安全设置-弹出框输入获取值
来源:cnblogs  作者:达叔小生  时间:2018/11/25 19:43:55  对本文有异议

小程序安全设置

  1. Page({
  2. /**
  3. * 页面的初始数据
  4. */
  5. data: {
  6. anquan: '',
  7. detailanquan: '',
  8. hiddenmodalput: true,
  9. //可以通过hidden是否掩藏弹出框的属性,来指定那个弹出框
  10. idCard: '',
  11. password: '',
  12. phone: '',
  13. email: '',
  14. wxUnionid: '',
  15. // 修改密码
  16. psd: "",
  17. newpsd: '',
  18. },
  19. // 获取身份认证:
  20. idCard: function(e) {
  21. this.setData({
  22. idCard: e.detail.value,
  23. })
  24. console.log("获取身份认证:" + this.data.idCard);
  25. },
  26. // 获取登录密码:
  27. password: function(e) {
  28. this.setData({
  29. password: e.detail.value,
  30. })
  31. console.log("获取登录密码:" + this.data.password);
  32. },
  33. // 获取绑定手机:
  34. phone: function(e) {
  35. this.setData({
  36. phone: e.detail.value,
  37. })
  38. console.log("获取绑定手机:" + this.data.phone);
  39. },
  40. // 获取绑定邮箱:
  41. email: function(e) {
  42. this.setData({
  43. email: e.detail.value,
  44. })
  45. console.log("获取绑定邮箱:" + this.data.email);
  46. },
  47. // 获取微信绑定:
  48. wxUnionid: function(e) {
  49. this.setData({
  50. wxUnionid: e.detail.value,
  51. })
  52. console.log("获取微信绑定:" + this.data.wxUnionid);
  53. },
  54. // 修改按钮
  55. sfrz: function(e) {
  56. console.log("身份认证", this.data.idCard);
  57. wx.request({
  58. method: 'POST',
  59. header: {
  60. 'Authorization': 'Bearer' + wx.getStorageSync('token'),
  61. },
  62. success(res) {
  63. console.log("保存成功", res.data);
  64. if (res == null || res.data == null) {
  65. console.error('网络请求失败');
  66. return;
  67. }
  68. wx.showToast({
  69. title: '保存成功',
  70. icon: 'success',
  71. duration: 500
  72. })
  73. }
  74. })
  75. },
  76. // 修改登录密码
  77. dlmm: function(e) {
  78. this.setData({
  79. hiddenmodalput: !this.data.hiddenmodalput
  80. })
  81. },
  82. cancelM: function(e) {
  83. this.setData({
  84. hiddenmodalput: true,
  85. })
  86. },
  87. confirmM: function(e) {
  88. console.log("原密码" + this.data.psd + "新密码" + this.data.newpsd);
  89. this.setData({
  90. hiddenmodalput: true,
  91. })
  92. wx.request({
  93. method: 'POST',
  94. header: {
  95. 'Authorization': 'Bearer' + wx.getStorageSync('token'),
  96. },
  97. success(res) {
  98. console.log("保存成功", res.data);
  99. if (res.data.code == 0) {
  100. wx.showToast({
  101. title: '保存失败',
  102. icon: 'success',
  103. duration: 500
  104. })
  105. }
  106. if (res == null || res.data == null) {
  107. console.error('网络请求失败');
  108. return;
  109. }
  110. wx.showToast({
  111. title: '保存成功',
  112. icon: 'success',
  113. duration: 500
  114. })
  115. }
  116. })
  117. },
  118. ipsd: function(e) {
  119. this.setData({
  120. psd: e.detail.value
  121. })
  122. },
  123. newipsd: function(e) {
  124. this.setData({
  125. newpsd: e.detail.value
  126. })
  127. },
  128. // 绑定手机
  129. bdsj: function(e) {
  130. console.log("绑定手机", this.data.phone);
  131. wx.request({
  132. method: 'POST',
  133. header: {
  134. 'Authorization': 'Bearer' + wx.getStorageSync('token'),
  135. },
  136. success(res) {
  137. console.log("保存成功", res.data);
  138. if (res == null || res.data == null) {
  139. console.error('网络请求失败');
  140. return;
  141. }
  142. wx.showToast({
  143. title: '保存成功',
  144. icon: 'success',
  145. duration: 500
  146. })
  147. }
  148. })
  149. },
  150. bdyx: function(e) {
  151. console.log("绑定邮箱", this.data.email);
  152. wx.request({
  153. method: 'POST',
  154. header: {
  155. 'Authorization': 'Bearer' + wx.getStorageSync('token'),
  156. },
  157. success(res) {
  158. console.log("保存成功", res.data);
  159. if (res == null || res.data == null) {
  160. console.error('网络请求失败');
  161. return;
  162. }
  163. wx.showToast({
  164. title: '保存成功',
  165. icon: 'success',
  166. duration: 500
  167. })
  168. }
  169. })
  170. },
  171. wxbd: function(e) {
  172. console.log("微信绑定", this.data.wxUnionid);
  173. wx.showModal({
  174. title: '提示',
  175. content: '解除微信绑定,注销账号! 是否确定?',
  176. success(res) {
  177. if (res.confirm) {
  178. console.log('用户点击确定')
  179. wx.request({
  180. data: this.data.wxUnionid,
  181. method: 'POST',
  182. header: {
  183. 'Authorization': 'Bearer' + wx.getStorageSync('token'),
  184. },
  185. success(res) {
  186. console.log("解绑成功", res.data);
  187. if (res == null || res.data == null) {
  188. console.error('网络请求失败');
  189. return;
  190. }
  191. wx.showToast({
  192. title: '保存成功',
  193. icon: 'success',
  194. duration: 500
  195. })
  196. }
  197. })
  198. } else if (res.cancel) {
  199. console.log('用户点击取消')
  200. }
  201. }
  202. })
  203. },
  204. /**
  205. * 生命周期函数--监听页面加载
  206. */
  207. onLoad: function(options) {
  208. var that = this;
  209. wx.request({
  210. method: 'GET',
  211. header: {
  212. 'Authorization': 'Bearer' + wx.getStorageSync('token')
  213. },
  214. success(res) {
  215. console.log("安全设置", res.data.data);
  216. var pass = res.data.data.user.password
  217. if (pass != null) {
  218. let password = "**********";
  219. let passs = password;
  220. that.setData({
  221. idCard: res.data.data.userDetail.idCard,
  222. // password: res.data.data.user.password,
  223. password: passs,
  224. phone: res.data.data.user.phone,
  225. email: res.data.data.user.email,
  226. wxUnionid: res.data.data.user.wxUnionid,
  227. })
  228. } else {
  229. that.setData({
  230. idCard: res.data.data.userDetail.idCard,
  231. password: res.data.data.user.password,
  232. phone: res.data.data.user.phone,
  233. email: res.data.data.user.email,
  234. wxUnionid: res.data.data.user.wxUnionid,
  235. })
  236. }
  237. wx.showToast({
  238. title: '加载成功',
  239. icon: 'loading',
  240. duration: 500
  241. })
  242. }
  243. })
  244. },
  245. /**
  246. * 生命周期函数--监听页面初次渲染完成
  247. */
  248. onReady: function() {
  249. },
  250. /**
  251. * 生命周期函数--监听页面显示
  252. */
  253. onShow: function() {
  254. },
  255. /**
  256. * 生命周期函数--监听页面隐藏
  257. */
  258. onHide: function() {
  259. },
  260. /**
  261. * 生命周期函数--监听页面卸载
  262. */
  263. onUnload: function() {
  264. },
  265. /**
  266. * 页面相关事件处理函数--监听用户下拉动作
  267. */
  268. onPullDownRefresh: function() {
  269. var that = this;
  270. wx.request({
  271. method: 'GET',
  272. header: {
  273. 'Authorization': 'Bearer' + wx.getStorageSync('token')
  274. },
  275. success(res) {
  276. console.log("安全设置", res.data.data);
  277. var pass = res.data.data.user.password
  278. if (pass != null) {
  279. let password = "**********";
  280. let passs = password;
  281. that.setData({
  282. idCard: res.data.data.userDetail.idCard,
  283. // password: res.data.data.user.password,
  284. password: passs,
  285. phone: res.data.data.user.phone,
  286. email: res.data.data.user.email,
  287. wxUnionid: res.data.data.user.wxUnionid,
  288. })
  289. } else {
  290. that.setData({
  291. idCard: res.data.data.userDetail.idCard,
  292. password: res.data.data.user.password,
  293. phone: res.data.data.user.phone,
  294. email: res.data.data.user.email,
  295. wxUnionid: res.data.data.user.wxUnionid,
  296. })
  297. }
  298. wx.showToast({
  299. title: '加载成功',
  300. icon: 'loading',
  301. duration: 500
  302. })
  303. },
  304. complete: function(res) {
  305. wx.stopPullDownRefresh();
  306. }
  307. })
  308. },
  309. /**
  310. * 页面上拉触底事件的处理函数
  311. */
  312. onReachBottom: function() {
  313. },
  314. /**
  315. * 用户点击右上角分享
  316. */
  317. onShareAppMessage: function() {
  318. }
  319. })
  1. <view class='item'>
  2. 登录密码
  3. <view class='bk'>
  4. <!-- name="password" -->
  5. <input class="textarea" placeholder="{{password}}" value='{{password}}' bindinput="password" maxlength='100' auto-height disabled/>
  6. </view>
  7. <button class='btn' bindtap='dlmm'>修改</button>
  8. <modal hidden="{{hiddenmodalput}}" title="修改密码" confirm-text="提交" cancel-text="取消" bindcancel="cancelM" bindconfirm="confirmM">
  9. <input bindinput='ipsd' type='text' placeholder="请输入原密码..." auto-focus/>
  10. <input bindinput='newipsd' type='password' placeholder="请输入新密码..." />
  11. </modal>
  12. </view>
 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号