C端小程序
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

123 satır
2.9 KiB

  1. const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px';
  2. var config = require("../../config/config.js");
  3. var app = getApp();
  4. const Http = require("../../utils/HttpBasics");
  5. const QR = require("../../utils/memberqrcode.js");
  6. const imgurl = require("../../utils/imgurl");
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. navigationBarHeight,
  13. myspeacialUrl: imgurl.myspeacial.url,
  14. teliconUrl: imgurl.telicon.url,
  15. wmhome: imgurl.wmhome.url,
  16. memberId:"000000",
  17. goHomeUrl: "",
  18. },
  19. phone: function (e) {
  20. console.log(e)
  21. let that = this;
  22. wx.makePhoneCall({
  23. phoneNumber: e.currentTarget.dataset.merchantlinkphone
  24. });
  25. },
  26. //是否授权手机号
  27. ifPhoneInfo() {
  28. let that = this;
  29. Http.get({
  30. url: config.api.checkPhoneStatus,
  31. data: {}
  32. }).then(res => {
  33. return
  34. }).catch(err => {
  35. wx.navigateTo({
  36. url: `/pages/getphoneInfo/index?mineFlag=index`,
  37. })
  38. })
  39. },
  40. /**
  41. * 生命周期函数--监听页面显示
  42. */
  43. onShow: function () {
  44. this.ifPhoneInfo()
  45. let that = this;
  46. that.setData({
  47. goHomeUrl: app.globalData.goHomeUrl,
  48. })
  49. console.log("渲染开始")
  50. Http.get({
  51. url: config.api.getDiscountInfo,
  52. data: {}
  53. })
  54. .then(res=>{
  55. that.setData({
  56. level: res.data.level ? res.data.level : ''
  57. })
  58. that.qrcode(res.data.id);
  59. that.setData({
  60. memberId: res.data.id
  61. })
  62. console.log(res.data.levelMerchantList)
  63. let discountMerchantList = [];
  64. res.data.levelMerchantList.map(file=>{
  65. if (file.discount != 100){
  66. discountMerchantList.push(file);
  67. }
  68. })
  69. that.setData({
  70. discountMerchantList: discountMerchantList,
  71. })
  72. })
  73. },
  74. goback: function () {
  75. let this_ = this
  76. wx.switchTab({
  77. url: this_.data.goHomeUrl,
  78. })
  79. },
  80. /**
  81. * 二维码
  82. */
  83. qrcode: function (memberId){
  84. let that = this;
  85. var size = that.setCanvasSize();
  86. let url = JSON.stringify({
  87. END: "C",
  88. TYPE: "memberCode",
  89. ID: memberId,
  90. });
  91. that.createQrCode(url, "mycanvas2", size.w, size.h);
  92. },
  93. createQrCode: function (url, canvasId, cavW, cavH) {
  94. //调用插件中的draw方法,绘制二维码图片
  95. let that = this;
  96. QR.api.draw(url, canvasId, cavW, cavH,function(res){
  97. that.setData({
  98. tempFilePath: res
  99. })
  100. });
  101. },
  102. //适配不同屏幕大小的canvas
  103. setCanvasSize: function () {
  104. var size = {};
  105. try {
  106. var res = wx.getSystemInfoSync();
  107. var scale = 750 / 400;
  108. //不同屏幕下canvas的适配比例;设计稿是750宽
  109. var width = res.windowWidth / scale;
  110. var height = width;
  111. //canvas画布为正方形
  112. size.w = width;
  113. size.h = height;
  114. } catch (e) {
  115. // Do something when catch error
  116. console.log("获取设备信息失败" + e);
  117. }
  118. return size;
  119. },
  120. })