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.

355 wiersze
8.3 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. templateId: [],
  15. aboutShow: false,
  16. navigationBarHeight,
  17. ifStoreApp: ifStoreApp,
  18. aboutUs: imgurl.aboutUs.url,
  19. rqCode: imgurl.barcode.url,
  20. banneColor: bgColor.colorFirst.user.banneColor,
  21. levelBg: bgColor.colorFirst.user.levelBg,
  22. view: bgColor.colorFirst.user.view,
  23. fenxiang: imgurl.fenxiang1.url,
  24. redirectUrl: imgurl.redirect.url,
  25. editUrl: imgurl.edit.url,
  26. activeUrl: imgurl.active.url,
  27. dingUrl: imgurl.ding.url,
  28. duihuan: imgurl.duihuan.url,
  29. shoppingAtlas: imgurl.shoppingAtlas.url,
  30. quansUrl: imgurl.quans.url,
  31. wmintegral: imgurl.wmintegral.url,
  32. cardiconUrl: imgurl.cardicon.url,
  33. myactivitygift: imgurl.myactivitygift.url,
  34. myactivity: imgurl.myactivity.url,
  35. cheUrl: imgurl.che.url,
  36. giftUrl: imgurl.gift.url,
  37. wmbarginicon: imgurl.wmbarginicon.url,
  38. wmspellgroup: imgurl.wmspellgroup.url,
  39. canIUse: wx.canIUse('official-account'),
  40. mineFlag: "",
  41. flag: 'hidden',
  42. score: '0',
  43. userId:"",
  44. memberName:"",
  45. memberLogo:"",
  46. curPhone: '',
  47. name: "",
  48. birthdate: "",
  49. sex: "",
  50. showEdit: false,
  51. ismember: false,
  52. canvasHidden: false,
  53. maskHidden: true,
  54. imagePath: '',
  55. appVersion: "",
  56. placeholder: ''
  57. },
  58. checkUserStatus() {
  59. let that = this;
  60. Http.get({
  61. url: config.api.checkPhoneStatus,
  62. data: {}
  63. }).then(res => {
  64. wx.navigateTo({
  65. url: '/pages/edit/edit',
  66. })
  67. }).catch(err => {
  68. wx.navigateTo({
  69. url: `/pages/getphoneInfo/index?mineFlag=mine`,
  70. })
  71. })
  72. },
  73. gotoPhoneInfo() {
  74. /**
  75. * 将值传到用户手机号授权的页面
  76. *
  77. */
  78. wx.redirectTo({
  79. url: `/pages/getphoneInfo/index?path=main`
  80. });
  81. },
  82. /* 判断是否授权*/
  83. userAuthorization() {
  84. Http.get({
  85. url: config.api.checkUserStatus,
  86. data: {
  87. token: app.globalData.token
  88. }
  89. }).then(res => {
  90. // this.getUserInfo()
  91. }).catch(err => {
  92. wx.navigateTo({
  93. url: `/pages/getuserinfo/index`,
  94. })
  95. })
  96. },
  97. /**
  98. * 跳转到成长值的页面
  99. */
  100. gotograde: function() {
  101. wx.navigateTo({
  102. url: '/pages/czdetail/czdetail',
  103. })
  104. },
  105. /**
  106. * 跳转到商场信息的页面
  107. */
  108. gomallInfo: function() {
  109. wx.navigateTo({
  110. url: '/pages/mallInfo/mallInfo',
  111. })
  112. },
  113. showVersion: function() {
  114. /**
  115. * 长按显示版本号
  116. */
  117. let that = this;
  118. if (that.data.flag == 'hidden') {
  119. that.setData({
  120. flag: 'show'
  121. });
  122. }
  123. },
  124. gotoedit: function() {
  125. this.checkUserStatus();
  126. },
  127. onLoad() {
  128. this.getLocation();
  129. this.updateScene();
  130. // this.getRoomId();
  131. // this.getRoomList();
  132. console.log(wx.getExtConfigSync())
  133. },
  134. //获取房间列表
  135. getRoomList() {
  136. debugger
  137. Http.get({
  138. url: config.api.getRoomList,
  139. data: {
  140. token: app.globalData.token,
  141. appId: config.weapp.AppId
  142. }
  143. }).then(res => {
  144. console.log(res)
  145. })
  146. },
  147. getRoomId() {
  148. let roomId = [3] // 填写具体的房间号,可通过下面【获取直播房间列表】 API 获取
  149. let customParams = encodeURIComponent(JSON.stringify({
  150. path: 'pages/index/index',
  151. pid: 1
  152. })) // 开发者在直播间页面路径上携带自定义参数(如示例中的path和pid参数),后续可以在分享卡片链接和跳转至商详页时获取,详见【获取自定义参数】、【直播间到商详页面携带参数】章节(上限600个字符,超过部分会被截断)
  153. console.log(customParams, 777777777)
  154. this.setData({
  155. roomId,
  156. customParams
  157. })
  158. },
  159. /**
  160. * 获得经纬度
  161. */
  162. getLocation() {
  163. let that = this;
  164. wx.getLocation({
  165. type: "wgs84",
  166. success: function(res) {
  167. console.log(res)
  168. if (res && res.longitude && res.latitude) {
  169. Http.post({
  170. url: config.api.updateLBS,
  171. data: {
  172. latitude: res.latitude,
  173. longitude: res.longitude
  174. }
  175. }).then(res => {
  176. console.log(res)
  177. })
  178. }
  179. },
  180. fail: error => {
  181. console.log(error);
  182. }
  183. })
  184. },
  185. /**
  186. * 用户更新scene
  187. */
  188. updateScene() {
  189. Http.post({
  190. url: config.api.updateScene,
  191. data: {
  192. scene: app.globalData.scene
  193. }
  194. }).then(res => {
  195. console.log(res)
  196. })
  197. },
  198. /**
  199. * 生命周期函数--监听页面显示
  200. */
  201. onShow: function() {
  202. let that = this;
  203. that.userAuthorization()
  204. if (typeof that.getTabBar === 'function' &&
  205. that.getTabBar()) {
  206. if (ifStoreApp == 1) {
  207. that.getTabBar().setData({
  208. selected: 1
  209. })
  210. } else if (ifStoreApp == 2) {
  211. that.getTabBar().setData({
  212. selected: 2
  213. })
  214. } else {
  215. that.getTabBar().setData({
  216. selected: 3
  217. })
  218. }
  219. }
  220. that.setData({
  221. appVersion: extConfig.appVersion,
  222. })
  223. /**
  224. * couponNum
  225. * couponNum2
  226. */
  227. let num = wx.getStorageSync('couponNum');
  228. let num1 = wx.getStorageSync('couponNum2');
  229. wx.hideTabBarRedDot({
  230. index: 3
  231. });
  232. if (num == 'couponNum1') {
  233. wx.setStorage({
  234. key: 'couponNum',
  235. data: "couponNum1",
  236. })
  237. that.setData({
  238. couponNum: "couponNum1"
  239. })
  240. } else if (num == 'couponNum') {
  241. that.setData({
  242. couponNum: "couponNum"
  243. })
  244. };
  245. if (num1 == 'couponNum3') {
  246. wx.setStorage({
  247. key: 'couponNum2',
  248. data: "couponNum3",
  249. })
  250. that.setData({
  251. couponNum2: "couponNum3"
  252. })
  253. } else if (num1 == 'couponNum2') {
  254. that.setData({
  255. couponNum2: "couponNum2"
  256. });
  257. };
  258. Http.get({
  259. url: config.api.getScore,
  260. data: {}
  261. }).then(res => {
  262. if (res.data.address && res.data.name && res.data.sex && res.data.birthdate) {
  263. that.setData({
  264. showEdit: true
  265. })
  266. }
  267. let curPhone = res.data.phone ? res.data.phone : '';
  268. if (curPhone) {
  269. let curPhoneList = curPhone.split('');
  270. let curPhoneList01 = [];
  271. curPhoneList.forEach((item, index) => {
  272. if (index >= 3 && index <= 6) {
  273. item = '*';
  274. }
  275. curPhoneList01.push(item);
  276. })
  277. curPhone = curPhoneList01.join('');
  278. }
  279. that.setData({
  280. score: res.data.score,
  281. curPhone: curPhone,
  282. levelName: res.data.levelName,
  283. userId: res.data.id
  284. })
  285. if (res.data.nickName) {
  286. that.setData({
  287. ismember: true,
  288. memberId: res.data.id
  289. })
  290. var size = this.setCanvasSize();
  291. var initUrl = JSON.stringify({
  292. flagid: res.data.id
  293. });
  294. }
  295. })
  296. .catch(err => {
  297. wx.showModal({
  298. title: '提示',
  299. content: err.errMsg,
  300. showCancel: false
  301. })
  302. })
  303. //暂时注释
  304. // that.getrun();
  305. //查询关于我们
  306. Http.get({
  307. url: config.api.getMallInfo,
  308. data: {}
  309. }).then(res => {
  310. if(res.code==200){
  311. this.setData({
  312. memberName:res.data.name,
  313. memberLogo:res.data.imgUrl
  314. })
  315. }
  316. if (res.data.businessHours !== '[]') {
  317. that.setData({
  318. aboutShow: true
  319. })
  320. } else {
  321. that.setData({
  322. aboutShow: false
  323. })
  324. }
  325. })
  326. .catch(err => {})
  327. },
  328. //适配不同屏幕大小的canvas
  329. setCanvasSize: function() {
  330. var size = {};
  331. try {
  332. var res = wx.getSystemInfoSync();
  333. var scale = 750 / 500;
  334. //不同屏幕下canvas的适配比例;设计稿是750宽
  335. var width = res.windowWidth / scale;
  336. var height = width;
  337. //canvas画布为正方形
  338. size.w = width;
  339. size.h = height;
  340. } catch (e) {
  341. // Do something when catch error
  342. console.log("获取设备信息失败" + e);
  343. }
  344. return size;
  345. },
  346. });