C端小程序
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

284 wiersze
8.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. this.getRoomId();
  99. console.log(wx.getExtConfigSync())
  100. },
  101. getRoomId() {
  102. let roomId = [3] // 填写具体的房间号,可通过下面【获取直播房间列表】 API 获取
  103. let customParams = encodeURIComponent(JSON.stringify({ path: 'pages/index/index', pid: 1 })) // 开发者在直播间页面路径上携带自定义参数(如示例中的path和pid参数),后续可以在分享卡片链接和跳转至商详页时获取,详见【获取自定义参数】、【直播间到商详页面携带参数】章节(上限600个字符,超过部分会被截断)
  104. console.log(customParams,777777777)
  105. this.setData({
  106. roomId,
  107. customParams
  108. })
  109. },
  110. /**
  111. * 获得经纬度
  112. */
  113. getLocation() {
  114. let that = this;
  115. wx.getLocation({
  116. type: "wgs84",
  117. success: function (res) {
  118. console.log(res)
  119. if (res && res.longitude && res.latitude) {
  120. Http.post({
  121. url: config.api.updateLBS,
  122. data: {
  123. latitude: res.latitude,
  124. longitude: res.longitude
  125. }
  126. }).then(res => {
  127. console.log(res)
  128. })
  129. }
  130. },
  131. fail: error => {
  132. console.log(error);
  133. }
  134. })
  135. },
  136. /**
  137. * 用户更新scene
  138. */
  139. updateScene() {
  140. Http.post({
  141. url: config.api.updateScene,
  142. data: {
  143. scene: app.globalData.scene
  144. }
  145. }).then(res => {
  146. console.log(res)
  147. })
  148. },
  149. /**
  150. * 生命周期函数--监听页面显示
  151. */
  152. onShow: function () {
  153. let that = this;
  154. if (typeof that.getTabBar === 'function' &&
  155. that.getTabBar()) {
  156. if (ifStoreApp == 1) {
  157. that.getTabBar().setData({
  158. selected: 1
  159. })
  160. } else if (ifStoreApp == 2) {
  161. that.getTabBar().setData({
  162. selected: 2
  163. })
  164. } else {
  165. that.getTabBar().setData({
  166. selected: 3
  167. })
  168. }
  169. }
  170. that.setData({
  171. appVersion: extConfig.appVersion,
  172. })
  173. /**
  174. * couponNum
  175. * couponNum2
  176. */
  177. let num = wx.getStorageSync('couponNum');
  178. let num1 = wx.getStorageSync('couponNum2');
  179. wx.hideTabBarRedDot({
  180. index: 3
  181. });
  182. if (num == 'couponNum1') {
  183. wx.setStorage({
  184. key: 'couponNum',
  185. data: "couponNum1",
  186. })
  187. that.setData({
  188. couponNum: "couponNum1"
  189. })
  190. } else if (num == 'couponNum') {
  191. that.setData({
  192. couponNum: "couponNum"
  193. })
  194. };
  195. if (num1 == 'couponNum3') {
  196. wx.setStorage({
  197. key: 'couponNum2',
  198. data: "couponNum3",
  199. })
  200. that.setData({
  201. couponNum2: "couponNum3"
  202. })
  203. } else if (num1 == 'couponNum2') {
  204. that.setData({
  205. couponNum2: "couponNum2"
  206. });
  207. };
  208. Http.get({
  209. url: config.api.getScore,
  210. data: {}
  211. }).then(res => {
  212. if (res.data.address && res.data.name && res.data.sex && res.data.birthdate) {
  213. that.setData({
  214. showEdit: true
  215. })
  216. }
  217. that.setData({
  218. score: res.data.score,
  219. levelName: res.data.levelName,
  220. })
  221. if (res.data.nickName) {
  222. that.setData({
  223. ismember: true,
  224. memberId: res.data.id
  225. })
  226. var size = this.setCanvasSize();
  227. var initUrl = JSON.stringify({
  228. flagid: res.data.id
  229. });
  230. }
  231. })
  232. .catch(err => {
  233. wx.showModal({
  234. title: '提示',
  235. content: err.errMsg,
  236. showCancel: false
  237. })
  238. })
  239. //暂时注释
  240. // that.getrun();
  241. //查询关于我们
  242. Http.get({
  243. url: config.api.getMallInfo,
  244. data: {}
  245. }).then(res => {
  246. console.log(res)
  247. if (res.data.businessHours !== '[]') {
  248. that.setData({
  249. aboutShow: true
  250. })
  251. } else {
  252. that.setData({
  253. aboutShow: false
  254. })
  255. }
  256. })
  257. .catch(err => {
  258. })
  259. },
  260. //适配不同屏幕大小的canvas
  261. setCanvasSize: function () {
  262. var size = {};
  263. try {
  264. var res = wx.getSystemInfoSync();
  265. var scale = 750 / 500;
  266. //不同屏幕下canvas的适配比例;设计稿是750宽
  267. var width = res.windowWidth / scale;
  268. var height = width;
  269. //canvas画布为正方形
  270. size.w = width;
  271. size.h = height;
  272. } catch (e) {
  273. // Do something when catch error
  274. console.log("获取设备信息失败" + e);
  275. }
  276. return size;
  277. },
  278. });