C端小程序
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

241 lignes
5.5 KiB

  1. var app = getApp();
  2. const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px'
  3. const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {}
  4. let ifStoreApp = extConfig.attr.ifStoreApp;
  5. const Http = require("../utils/HttpBasics");
  6. const imgurl = require("../utils/imgurl");
  7. var config = require("../config/config.js");
  8. const bgColor = require("../utils/bgColor.js")
  9. Page({
  10. /**
  11. * 页面的初始数据
  12. */
  13. data: {
  14. navigationBarHeight,
  15. ifStoreApp:ifStoreApp,
  16. banneColor: bgColor.colorFirst.user.banneColor,
  17. levelBg: bgColor.colorFirst.user.levelBg,
  18. view: bgColor.colorFirst.user.view,
  19. redirectUrl: imgurl.redirect.url,
  20. editUrl: imgurl.edit.url,
  21. activeUrl: imgurl.active.url,
  22. dingUrl: imgurl.ding.url,
  23. quansUrl: imgurl.quans.url,
  24. wmintegral: imgurl.wmintegral.url,
  25. cardiconUrl: imgurl.cardicon.url,
  26. myactivitygift: imgurl.myactivitygift.url,
  27. myactivity: imgurl.myactivity.url,
  28. cheUrl: imgurl.che.url,
  29. giftUrl: imgurl.gift.url,
  30. wmbarginicon: imgurl.wmbarginicon.url,
  31. wmspellgroup: imgurl.wmspellgroup.url,
  32. canIUse: wx.canIUse('official-account'),
  33. mineFlag:"",
  34. flag: 'hidden',
  35. score: '0',
  36. name: "",
  37. birthdate: "",
  38. sex: "",
  39. showEdit: false,
  40. ismember: false,
  41. canvasHidden: false,
  42. maskHidden: true,
  43. imagePath: '',
  44. appVersion: "",
  45. placeholder: ''
  46. },
  47. checkUserStatus() {
  48. let that = this;
  49. Http.get({
  50. url: config.api.checkPhoneStatus,
  51. data: {}
  52. }).then(res => {
  53. }).catch(err => {
  54. wx.navigateTo({
  55. url: `/pages/getphoneInfo/index?mineFlag=mine`,
  56. })
  57. })
  58. },
  59. /**
  60. * 跳转到成长值的页面
  61. */
  62. gotograde: function() {
  63. wx.navigateTo({
  64. url: '/pages/czdetail/czdetail',
  65. })
  66. },
  67. showVersion: function() {
  68. /**
  69. * 长按显示版本号
  70. */
  71. let that = this;
  72. if (that.data.flag == 'hidden') {
  73. that.setData({
  74. flag: 'show'
  75. });
  76. }
  77. },
  78. gotoedit: function() {
  79. wx.navigateTo({
  80. url: '/pages/edit/edit',
  81. })
  82. },
  83. onLoad() {
  84. this.getLocation();
  85. this.updateScene();
  86. },
  87. /**
  88. * 获得经纬度
  89. */
  90. getLocation() {
  91. let that = this;
  92. wx.getLocation({
  93. type: "wgs84",
  94. success: function(res) {
  95. console.log(res)
  96. if (res && res.longitude && res.latitude) {
  97. Http.post({
  98. url: config.api.updateLBS,
  99. data: {
  100. latitude: res.latitude,
  101. longitude: res.longitude
  102. }
  103. }).then(res => {
  104. console.log(res)
  105. })
  106. }
  107. },
  108. fail: error => {
  109. console.log(error);
  110. }
  111. })
  112. },
  113. /**
  114. * 用户更新scene
  115. */
  116. updateScene(){
  117. Http.post({
  118. url: config.api.updateScene,
  119. data: {
  120. scene: app.globalData.scene
  121. }
  122. }).then(res => {
  123. console.log(res)
  124. })
  125. },
  126. /**
  127. * 生命周期函数--监听页面显示
  128. */
  129. onShow: function() {
  130. let that = this;
  131. if (typeof that.getTabBar === 'function' &&
  132. that.getTabBar()) {
  133. if (ifStoreApp==1){
  134. that.getTabBar().setData({
  135. selected: 1
  136. })
  137. } else if(ifStoreApp == 2){
  138. that.getTabBar().setData({
  139. selected: 2
  140. })
  141. }else{
  142. that.getTabBar().setData({
  143. selected: 3
  144. })
  145. }
  146. }
  147. that.checkUserStatus();
  148. that.setData({
  149. appVersion: extConfig.appVersion,
  150. })
  151. /**
  152. * couponNum
  153. * couponNum2
  154. */
  155. let num = wx.getStorageSync('couponNum');
  156. let num1 = wx.getStorageSync('couponNum2');
  157. wx.hideTabBarRedDot({
  158. index: 3
  159. });
  160. if (num == 'couponNum1') {
  161. wx.setStorage({
  162. key: 'couponNum',
  163. data: "couponNum1",
  164. })
  165. that.setData({
  166. couponNum: "couponNum1"
  167. })
  168. } else if (num == 'couponNum') {
  169. that.setData({
  170. couponNum: "couponNum"
  171. })
  172. };
  173. if (num1 == 'couponNum3') {
  174. wx.setStorage({
  175. key: 'couponNum2',
  176. data: "couponNum3",
  177. })
  178. that.setData({
  179. couponNum2: "couponNum3"
  180. })
  181. } else if (num1 == 'couponNum2') {
  182. that.setData({
  183. couponNum2: "couponNum2"
  184. });
  185. };
  186. Http.get({
  187. url: config.api.getScore,
  188. data: {}
  189. }).then(res => {
  190. if (res.data.address && res.data.name && res.data.sex && res.data.birthdate) {
  191. that.setData({
  192. showEdit: true
  193. })
  194. }
  195. that.setData({
  196. score: res.data.score,
  197. levelName: res.data.levelName,
  198. })
  199. if (res.data.nickName) {
  200. that.setData({
  201. ismember: true,
  202. memberId: res.data.id
  203. })
  204. var size = this.setCanvasSize();
  205. var initUrl = JSON.stringify({
  206. flagid: res.data.id
  207. });
  208. }
  209. })
  210. .catch(err => {
  211. wx.showModal({
  212. title: '提示',
  213. content: err.errMsg,
  214. showCancel: false
  215. })
  216. })
  217. //暂时注释
  218. // that.getrun();
  219. },
  220. //适配不同屏幕大小的canvas
  221. setCanvasSize: function() {
  222. var size = {};
  223. try {
  224. var res = wx.getSystemInfoSync();
  225. var scale = 750 / 500;
  226. //不同屏幕下canvas的适配比例;设计稿是750宽
  227. var width = res.windowWidth / scale;
  228. var height = width;
  229. //canvas画布为正方形
  230. size.w = width;
  231. size.h = height;
  232. } catch (e) {
  233. // Do something when catch error
  234. console.log("获取设备信息失败" + e);
  235. }
  236. return size;
  237. }
  238. });