C端小程序
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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