C端小程序
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

272 Zeilen
6.0 KiB

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