index.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <view class="content">
  3. <!-- <button
  4. type="default"
  5. open-type="getPhoneNumber"
  6. @getphonenumber="decryptPhoneNumber"
  7. >
  8. 微信授权一键登录
  9. </button>
  10. <button @click="wxHttpTest" style="margin-top: 10rps">
  11. miniprogram http请求
  12. </button> -->
  13. uid:{{uid}}
  14. </view>
  15. </template>
  16. <script>
  17. export default {
  18. data() {
  19. return {
  20. uid:''
  21. };
  22. },
  23. onLoad(){
  24. this.uid = getApp().globalData.uid
  25. uni.$on('user_getUid',this.uidCallback)
  26. },
  27. onUnload(){
  28. uni.$off('user_getUid',this.uidCallback)
  29. },
  30. methods: {
  31. uidCallback(data){
  32. this.uid = data.uid
  33. },
  34. decryptPhoneNumber(e) {
  35. console.log(e.detail.errMsg);
  36. console.log(e.detail.iv);
  37. console.log(e.detail.encryptedData);
  38. },
  39. wxHttpTest() {
  40. //try{
  41. this.$request({
  42. server: 2,
  43. servant: 1005,
  44. data: {
  45. // phone:Buffer.from('3246541321'),
  46. phone: "3246541321",
  47. type: 1,
  48. //verifyInfo:Buffer.from('asdasd')
  49. verifyInfo: "asdasd",
  50. data: {},
  51. },
  52. }).then(
  53. (res) => {
  54. console.log(res);
  55. /* res的结构
  56. {
  57. code:0,错误码 number类型
  58. msg:"",错误消息 string类型
  59. data:对应loginRsp的js对象
  60. }
  61. */
  62. if (res.code === 0) {
  63. //成功
  64. } else {
  65. //失败
  66. }
  67. },
  68. (err) => {
  69. //出现异常
  70. console.log(err);
  71. }
  72. );
  73. },
  74. },
  75. };
  76. </script>
  77. <style>
  78. .content {
  79. display: flex;
  80. flex-direction: column;
  81. margin: 20rpx;
  82. }
  83. </style>