C端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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