index.vue 1.3 KB

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