抖音c端
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 2 gadiem
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 2 gadiem
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 2 gadiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623
  1. // const extConfig = tt.getExtConfigSync ? tt.getExtConfigSync() : {}
  2. // let ifStoreApp = extConfig.attr.ifStoreApp;
  3. // let businessSwitch = extConfig.attr.businessSwitch
  4. // let mch_id = extConfig.attr.mchId
  5. const navigationBarHeight = (getApp().statusBarHeight + 60) + "px"
  6. const navigationBarHeight1 = (getApp().statusBarHeight + 50) + "px"
  7. const Http = require("../utils/HttpBasics");
  8. const imgurl = require("../utils/imgurl");
  9. const config = require("../config/config");
  10. const QR = require("../utils/memberqrcode.js");
  11. const util = require("../utils/util");
  12. const bgColor = require("../utils/bgColor.js")
  13. let app = getApp();
  14. Page({
  15. data: {
  16. userAvatarUrl: '',
  17. userName: '',
  18. // aa: (app.statusBarHeight + 60) + "rpx",
  19. noDataFlag: false,
  20. businessKey: 0,
  21. businePageNum: 1,
  22. credit: 0,
  23. businessList: [], //优选好物导航
  24. businessData: [], //优选好物数据
  25. topicObj2: null, //欢乐城首页限时抢购
  26. topicObj3: null, //欢乐城首页砍价
  27. topicObj4: null, //欢乐城首页拼团
  28. topicObj5: null, //欢乐城首页消费卡
  29. topicObj6: null, //欢乐城首页积分商城
  30. specialLsit: [], //欢乐城首页专题
  31. marketName: "", //商场名称
  32. mouldType: null,
  33. navLineHeight: ((app.statusBarHeight + app.statusBarHeight) + 50) + "px",
  34. navImgHeight: (((app.statusBarHeight + app.statusBarHeight) + 34) / 2) + "px",
  35. huanlechengImgurl: "https://formall.oss-accelerate.aliyuncs.com/cimg/v20211214/",
  36. // mch_id: mch_id,
  37. goUrl: "", //商圈跳转链接
  38. accreditFlag: 1, //1是未授权微信且未授权手机号 2授权了微信 没授权手机号 3微信和手机号都授权了
  39. // businessSwitch: businessSwitch,
  40. typeLsit: {},
  41. showLocationIf: true,
  42. // ifStoreApp: ifStoreApp,
  43. navigationBarTitle: '首页',
  44. navigationBarHeight,
  45. navigationBarHeight1,
  46. chengzhangBox: bgColor.colorFirst.main.chengzhangBox,
  47. activeColor: bgColor.colorFirst.main.activeColor,
  48. qg: bgColor.colorFirst.main.qg,
  49. newUrl: "",
  50. cover: "",
  51. kanjia: imgurl.kanjia.url,
  52. pintuan: imgurl.pintuan.url,
  53. xiaofeika: imgurl.xiaofeika.url,
  54. xingyun: imgurl.xingyun.url,
  55. jfshangcheng: imgurl.jfshangcheng.url,
  56. toutiao: imgurl.toutiao.url,
  57. more: imgurl.more.url,
  58. giftHr: imgurl.giftHr.url,
  59. giftHr: imgurl.giftHr.url,
  60. next: imgurl.next.url,
  61. usergift: imgurl.usergift.url,
  62. guanbi1: imgurl.guanbi1.url,
  63. icon0001: imgurl.icon0001.url,
  64. icon0002: imgurl.icon0002.url,
  65. icon0003: imgurl.icon0003.url,
  66. icon0004: imgurl.icon0004.url,
  67. icon0005: imgurl.icon0005.url,
  68. icon0006: imgurl.icon0006.url,
  69. icon0007: imgurl.icon0007.url,
  70. icon0008: imgurl.icon0008.url,
  71. barcode: imgurl.barcode.url,
  72. leftarrows: imgurl.leftarrows.url,
  73. newcard: imgurl.newcard.url,
  74. newseckill: imgurl.newseckill.url,
  75. newbargain: imgurl.newbargain.url,
  76. newgroup: imgurl.newgroup.url,
  77. product: imgurl.product.url,
  78. barginicon: imgurl.barginicon.url,
  79. pintuan: imgurl.pintuan.url,
  80. live: imgurl.live.url,
  81. duihuan: imgurl.duihuan.url,
  82. market: app.globalData.market,
  83. list: [],
  84. xslist: [],
  85. loading: true,
  86. fistLogin: null,
  87. alphaData: null,
  88. alphaData1: null,
  89. swiperCurrent: 0,
  90. title: null,
  91. weappShareTitle: '', //分享标题
  92. weappShareCoverImg: '', //分享图片
  93. desc: null,
  94. scrollTop: 0,
  95. showGame: false,
  96. showTopic: false,
  97. showQg: false,
  98. gamedata: {},
  99. couponId: '', //游戏返回时传回的字段
  100. played: false, //从游戏页面跳回首页返回true
  101. havePlayEd: app.globalData.havePlayEd,
  102. havePlayEd1: app.globalData.havePlayEd1,
  103. staticGamedata: {},
  104. showIf: false,
  105. showPages: false,
  106. display: 'none',
  107. display1: 'none',
  108. optionsData: null,
  109. page: 1, // 刷新进入页面时已经加载了第一页数据,onReachBottom时 page++,从第2页开始加载
  110. openId: '',
  111. showGg: false,
  112. ggdata: {},
  113. liveFlag: 0, //直播按钮显隐标志位
  114. squareName: "", //当前广场
  115. isShowSqare: false,
  116. moduleList: [], //按钮列表
  117. currentMall: '富茂广场',
  118. shopList: [],
  119. mallTenantId: tt.getStorageSync('mallTenantId') || '',
  120. index: tt.getStorageSync('mallIndex') || 0,
  121. locateData: {},
  122. scanIn: false, // 扫码进入首页
  123. scanInTenantId: '',
  124. scene: ""
  125. },
  126. getCongig() { //获取小程序是否开通授权手机号
  127. Http.get({
  128. url: config.api.getConfig,
  129. data: {
  130. key: "douyinPhoneStatus"
  131. }
  132. }).then(res => {
  133. app.globalData.ifCongPh = res.data ? res.data : 1
  134. }).catch(err => {
  135. app.globalData.ifCongPh = 1
  136. })
  137. },
  138. mallSync() {
  139. this.setData({
  140. mallTenantId: tt.getStorageSync('mallTenantId') || '',
  141. index: tt.getStorageSync('mallIndex') || 0,
  142. })
  143. },
  144. getsubMallList() {
  145. Http.get({
  146. url: '/mall/subMall?isAll=1',
  147. }).then(res => {
  148. tt.setStorageSync('shopList', JSON.stringify(res.data));
  149. if (this.data.scanIn) {
  150. console.log('Over Here!!!!!!!!!!!!!!');
  151. let obj = {}
  152. let i = 0
  153. res.data.forEach((item, index) => {
  154. if (item.tenantId == this.data.scanInTenantId) {
  155. obj = item
  156. i = index
  157. return
  158. }
  159. })
  160. console.log(obj, 'obj');
  161. this.setData({
  162. shopList: res.data,
  163. mallTenantId: obj.tenantId,
  164. index: i
  165. });
  166. tt.setStorageSync('mallTenantId', obj.tenantId)
  167. tt.setStorageSync('mallIndex', i)
  168. } else {
  169. console.log('IIIOver Here!!!!!!!!!!!!!!');
  170. this.setData({
  171. shopList: res.data,
  172. mallTenantId: tt.getStorageSync('mallTenantId') || res.data[0].tenantId
  173. });
  174. if (!tt.getStorageSync('mallTenantId') && res.data.length > 1) {
  175. tt.setStorageSync('mallTenantId', res.data[0].tenantId)
  176. tt.setStorageSync('mallIndex', 0)
  177. }
  178. const locationSwitch = tt.getStorageSync('locationSwitch');
  179. if (locationSwitch) {
  180. this.getLocation()
  181. }
  182. }
  183. }).catch(err => {
  184. console.log(err, 'err');
  185. })
  186. },
  187. bindPickerChange(e, indexIn, id) {
  188. const index = e ? e.detail.value : indexIn
  189. const mallTenantId = id || this.data.shopList[index].tenantId
  190. tt.setStorageSync('mallTenantId', mallTenantId)
  191. tt.setStorageSync('mallIndex', index)
  192. this.setData({
  193. index: index,
  194. mallTenantId: mallTenantId,
  195. businePageNum: 1, // 切换广场后将页码切换至1
  196. noDataFlag: false
  197. });
  198. this.getBannerlist();
  199. this.getBusinessList()
  200. this.getCouponChannelList(this.data.businessKey)
  201. },
  202. getBusineData(e) {
  203. this.setData({
  204. businePageNum: 1,
  205. businessKey: e.detail,
  206. noDataFlag: false,
  207. })
  208. this.getCouponChannelList(e.detail)
  209. },
  210. getBusinessList() { //获取优选导航
  211. Http.get({
  212. url: config.api.businessList,
  213. data: {
  214. filter: 2,
  215. mallTenantId: this.data.mallTenantId || this.data.scanInTenantId || "",
  216. }
  217. }).then(res => {
  218. this.setData({
  219. businessList: [{
  220. id: 0,
  221. title: "全部",
  222. type: 1
  223. }].concat(res.data)
  224. });
  225. }).catch(err => {
  226. tt.showModal({
  227. title: '提示',
  228. content: err.message ? err.message : err.data,
  229. showCancel: false
  230. })
  231. })
  232. },
  233. getCouponChannelList(key) {
  234. const that = this
  235. if (that.data.noDataFlag) {
  236. return
  237. }
  238. tt.showLoading({
  239. title: "加载中"
  240. });
  241. let param = {}
  242. if (key == 0) {
  243. param = {
  244. pageNum: that.data.businePageNum,
  245. pageSize: 6,
  246. targetAd: 101,
  247. mallTenantId: tt.getStorageSync('mallTenantId') || that.data.scanInTenantId || ""
  248. }
  249. } else {
  250. param = {
  251. pageNum: that.data.businePageNum,
  252. pageSize: 6,
  253. business: key,
  254. targetAd: 101,
  255. mallTenantId: tt.getStorageSync('mallTenantId') || that.data.scanInTenantId || ""
  256. }
  257. }
  258. Http.get({
  259. url: config.api.couponChannelList,
  260. data: param
  261. }).then(res => {
  262. if (res.data.list && res.data.list.length != 0) {
  263. let tempLsit = that.data.businessData
  264. let data = res.data.list
  265. data.map(item => {
  266. if (item.salePriceStr && item.salePriceStr.indexOf('.') != -1) {
  267. let str = item.salePriceStr.split('.')
  268. item.salePriceStrQ = str[0]
  269. item.salePriceStrH = str[1]
  270. }
  271. item.sale = item.inventory - item.remainInventory
  272. })
  273. if (that.data.businePageNum > 1) {
  274. that.setData({
  275. businessData: [...tempLsit, ...data]
  276. })
  277. } else {
  278. that.setData({
  279. businessData: data
  280. })
  281. }
  282. } else {
  283. if (that.data.businePageNum != 1) {
  284. that.setData({
  285. noDataFlag: true
  286. })
  287. } else {
  288. that.setData({
  289. noDataFlag: true,
  290. businessData: []
  291. })
  292. }
  293. }
  294. tt.hideLoading();
  295. console.log(that.data.businessData, 'businessData');
  296. }).catch(err => {
  297. tt.hideLoading();
  298. tt.showModal({
  299. title: '提示',
  300. content: err.message ? err.message : err.data,
  301. showCancel: false
  302. })
  303. })
  304. },
  305. goPage(e) {
  306. let obj = e.currentTarget.dataset.obj
  307. console.log(obj, "obj")
  308. if (obj.linkType == 1) {
  309. if (obj.linkUrl == "/pages/game/index") {
  310. // this.gotogame()
  311. } else {
  312. tt.navigateTo({
  313. url: obj.linkUrl,
  314. })
  315. }
  316. //小程序内部跳转
  317. } else if (obj.linkType == 2) {
  318. //跳转到外部小程序
  319. tt.navigateToMiniProgram({
  320. appId: obj.outLinkAppid,
  321. path: obj.linkUrl ? obj.linkUrl : '',
  322. fail: err => {
  323. tt.showModal({
  324. title: '提示',
  325. content: err,
  326. showCancel: false
  327. })
  328. }
  329. })
  330. }
  331. },
  332. //获取按钮列表
  333. getModule() {
  334. Http.get({
  335. url: config.api.wxCustomizeModule
  336. }).then(res => {
  337. this.setData({
  338. moduleList: res.data,
  339. })
  340. }).catch(err => {
  341. if (err.status != 404)
  342. tt.showModal({
  343. title: '提示',
  344. content: err.message ? err.message : err.data,
  345. showCancel: false
  346. })
  347. })
  348. },
  349. //判断用户是否授权
  350. uesrInfo() {
  351. Http.get({
  352. url: config.api.checkUserStatus,
  353. data: {
  354. token: app.globalData.token
  355. }
  356. }).then(res => {
  357. Http.get({
  358. url: config.api.checkPhoneStatus
  359. }).then(res => { //全部授权
  360. this.setData({
  361. accreditFlag: 3
  362. })
  363. }).catch(err => {
  364. if (err.code == 11005) { //未授权手机号
  365. this.setData({
  366. accreditFlag: 2
  367. })
  368. } else {
  369. tt.showToast({
  370. title: err.message,
  371. icon: 'none',
  372. duration: 2000,
  373. mask: false
  374. });
  375. }
  376. })
  377. }).catch(err => {
  378. if (err.code == 11004) { //未授权微信
  379. this.setData({
  380. accreditFlag: 1
  381. })
  382. } else {
  383. tt.showToast({
  384. title: err.message,
  385. icon: 'none',
  386. duration: 2000,
  387. mask: false
  388. });
  389. }
  390. })
  391. },
  392. //获取当前广场名
  393. //跳转到每日签到
  394. goSign() {
  395. tt.navigateTo({
  396. url: '/pages/activityCalendar/activityCalendar',
  397. })
  398. },
  399. //活动日历
  400. goCalendar() {
  401. tt.navigateTo({
  402. url: '/pages/dateLsit/dateLsit',
  403. })
  404. },
  405. //跳转到其他广场列表
  406. goSquareList() {
  407. if (this.data.isShowSqare) {
  408. tt.navigateTo({
  409. url: '/pages/location/location',
  410. })
  411. }
  412. },
  413. goLive() {
  414. tt.navigateTo({
  415. url: '/pages2/live/livelist/index',
  416. })
  417. },
  418. alphaClick1: function (even) {
  419. var animation = tt.createAnimation({})
  420. animation.opacity(0).step({
  421. duration: 2000
  422. })
  423. this.setData({
  424. alphaData: animation.export()
  425. })
  426. },
  427. alphaClick: function (even) {
  428. var animation = tt.createAnimation({})
  429. animation.opacity(0).step({
  430. duration: 2000
  431. })
  432. this.setData({
  433. alphaData1: animation.export()
  434. })
  435. },
  436. // 我的卡包
  437. mycard: function () {
  438. tt.navigateTo({
  439. url: '/pages/cardorder/index/index',
  440. })
  441. },
  442. //我的券包
  443. mycoupon: function () {
  444. tt.navigateTo({
  445. url: '/pages/couponorder/index/index',
  446. })
  447. },
  448. gotoSpellGroup: function () {
  449. tt.navigateTo({
  450. url: '/pages/spellGroup/spellGroup',
  451. })
  452. },
  453. qrcode: function () {
  454. var that = this;
  455. let memberId = that.data.memberId;
  456. if (memberId) {
  457. tt.navigateTo({
  458. url: '/pages/specialcourtesy/specialcourtesy'
  459. })
  460. }
  461. },
  462. //跳往限时秒杀
  463. gotoRushBuy: function () {
  464. tt.navigateTo({
  465. url: '/pages/rushToBuy/index',
  466. })
  467. },
  468. swiperChange: function (e) {
  469. this.setData({
  470. swiperCurrent: e.detail.current
  471. });
  472. },
  473. gotogame: function () {
  474. let that = this;
  475. if (!that.data.showIf) {
  476. tt.showToast({
  477. title: '暂无游戏频道',
  478. icon: "none",
  479. duration: 3000
  480. })
  481. } else {
  482. Http.get({
  483. url: config.api.checkUserStatus,
  484. data: {
  485. token: app.globalData.token
  486. }
  487. }).then(res1 => {
  488. app.globalData.type = 'gm'
  489. Http.get({
  490. url: config.api.checkPhoneStatus,
  491. data: {}
  492. }).then(res => {
  493. var data = {
  494. couponChannelId: "" + that.data.couponChannelId,
  495. couponId: "" + that.data.couponId
  496. };
  497. if (that.data.couponChannelId == null) {
  498. var data = {
  499. couponId: "" + that.data.couponId
  500. };
  501. }
  502. tt.redirectTo({
  503. url: '/pages/game/index?url=' + that.data.staticGamedata.url + "&id=" + that.data.staticGamedata.id + "&gameId=" + that.data.staticGamedata.gameId,
  504. })
  505. }).catch(err => {
  506. if (err.code == 11005) {
  507. // 用户手机未授权
  508. /**
  509. * 将值传到用户手机号授权的页面
  510. *
  511. */
  512. app.globalData.skipUrl = '/pages/game/index?url=' + that.data.staticGamedata.url + "&id=" + that.data.staticGamedata.id + "&gameId=" + that.data.staticGamedata.gameId,
  513. app.globalData.skip = 'redirectTo'
  514. tt.redirectTo({
  515. url: "/pages/getphoneInfo/index?path=index&url=" + that.data.staticGamedata.url + "&id=" + that.data.staticGamedata.id + "&gameId=" + that.data.staticGamedata.gameId,
  516. });
  517. } else if (err.code == 11006) {
  518. // 用户手机已加密
  519. tt.redirectTo({
  520. url: "/pages/phoneinput/phoneinput?path=index&url=" + that.data.staticGamedata.url + "&id=" + that.data.staticGamedata.id + "&gameId=" + that.data.staticGamedata.gameId,
  521. });
  522. } else {
  523. tt.showToast({
  524. title: err.message,
  525. icon: 'none',
  526. duration: 2000,
  527. mask: false
  528. });
  529. }
  530. })
  531. }).catch(err => {
  532. if (err.code == 11004) { //未授权微信
  533. app.globalData.type = 'gm'
  534. tt.redirectTo({
  535. url: "/pages/getuserinfo/index?path=index&url=" + that.data.staticGamedata.url + "&id=" + that.data.staticGamedata.id + "&gameId=" + that.data.staticGamedata.gameId,
  536. });
  537. } else {
  538. tt.showToast({
  539. title: err.message,
  540. icon: 'none',
  541. duration: 2000,
  542. mask: false
  543. });
  544. }
  545. })
  546. }
  547. },
  548. mySpecial: function () {
  549. console.log("special");
  550. tt.navigateTo({
  551. url: '/pages/specialcourtesy/specialcourtesy',
  552. })
  553. },
  554. //是否属于集团
  555. ifShowSqare() {
  556. if (tt.getStorageSync("squareList")) {
  557. this.setData({
  558. isShowSqare: true
  559. })
  560. } else {
  561. this.setData({
  562. isShowSqare: false
  563. })
  564. }
  565. },
  566. /**
  567. * 获取全局样式
  568. */
  569. getType() {
  570. Http.get({
  571. url: config.api.setType,
  572. data: {
  573. mouldType: app.globalData.mouldType
  574. }
  575. }).then(res => {
  576. const {
  577. code,
  578. data
  579. } = res
  580. if (code == 200) {
  581. app.globalData.typeLsit = data
  582. this.setData({
  583. typeLsit: data,
  584. })
  585. }
  586. })
  587. },
  588. /**
  589. * 生命周期函数--监听页面初次渲染完成
  590. */
  591. onLoad: function (options) {
  592. console.log(options, 'options');
  593. let that = this;
  594. let optionss;
  595. const locationSwitch = options.type || ''
  596. tt.setStorageSync('locationSwitch', locationSwitch);
  597. if (options.tenantId) {
  598. that.setData({
  599. scanIn: true,
  600. scanInTenantId: options.tenantId
  601. })
  602. console.log(that.data.scanInTenantId, 'scanInTenantId');
  603. }
  604. let openId = tt.getStorageSync('openId')
  605. if (tt.getStorageSync('options')) {
  606. optionss = JSON.parse(tt.getStorageSync('options'));
  607. }
  608. if (options.played == "true") {
  609. that.setData({
  610. played: true
  611. })
  612. }
  613. if (optionss && optionss.couponChannelId || optionss && optionss.orderId) {
  614. that.setData({
  615. optionsData: optionss
  616. })
  617. that.getWeapNote(optionss.couponChannelId, optionss.orderId);
  618. } else {
  619. that.getWeapNote()
  620. }
  621. //获取条形码
  622. // util.barcode("barcode", optionss.quancode, 510, 100);
  623. // console.log(Http.headers.token, "?")
  624. },
  625. /**
  626. * 获得经纬度
  627. */
  628. getLocation() {
  629. console.log('getLocation');
  630. let that = this;
  631. tt.getLocation({
  632. type: "wgs84",
  633. // isHighAccuracy: true,
  634. success: function (res) {
  635. console.log(res, 'getLocation')
  636. const locateData = {
  637. latitude: res.latitude,
  638. longitude: res.longitude,
  639. }
  640. that.setData({
  641. locateData: locateData
  642. })
  643. if (res && res.longitude && res.latitude) {
  644. Http.post({
  645. url: config.api.updateLBS,
  646. data: {
  647. latitude: res.latitude,
  648. longitude: res.longitude,
  649. city: res.city
  650. }
  651. }).then(res => {
  652. // 获取到的用户的坐标
  653. const latitudeNow = that.data.locateData.latitude
  654. const longitudeNow = that.data.locateData.longitude
  655. const mallLocationArr = []
  656. const shopList = JSON.parse(tt.getStorageSync('shopList'));
  657. shopList.forEach((item, index) => {
  658. const obj = {
  659. latitude: item.latitude,
  660. longitude: item.longitude,
  661. mallTenantId: item.tenantId,
  662. index: index
  663. }
  664. mallLocationArr.push(obj)
  665. })
  666. console.log(mallLocationArr, 'mallLocationArr');
  667. const tempArr = shopList
  668. const bloobArr = []
  669. // 调整广场列表数据
  670. mallLocationArr.forEach((item, index) => {
  671. const distanceData = that.getDistances(latitudeNow, longitudeNow, item.latitude, item.longitude)
  672. tempArr[index].distance_str = distanceData.distance_str
  673. tempArr[index].distanceName = tempArr[index].name + ' ' + distanceData.distance_str
  674. tempArr[index].distance = distanceData.distance
  675. bloobArr.push(distanceData.distance)
  676. })
  677. that.setData({
  678. shopList: tempArr
  679. })
  680. // 通过排序获取最近广场
  681. const nearestDistance = that.bloob(bloobArr)[0]
  682. const nearestArr = that.data.shopList.filter((item, index) => {
  683. // 切换至最近的广场
  684. const locationFlag = tt.getStorageSync('locationFlag');
  685. if ((item.distance == nearestDistance)) {
  686. if (locationFlag) {
  687. that.bindPickerChange('', index, item.tenantId)
  688. tt.setStorageSync('locationFlag', false);
  689. } else {
  690. that.bindPickerChange('', tt.getStorageSync('mallIndex'), tt.getStorageSync('mallTenantId'))
  691. }
  692. return true
  693. } else {
  694. return false
  695. }
  696. })
  697. console.log(nearestArr[0], 'nearestArr');
  698. })
  699. }
  700. },
  701. // 拒绝提供定位权限
  702. fail: error => {
  703. console.log(error);
  704. const shopList = JSON.parse(tt.getStorageSync('shopList'));
  705. let obj = {}
  706. shopList.forEach((item, index) => {
  707. if (item.defaultSign == 1) {
  708. const tempObj = {
  709. index: index,
  710. tenantId: item.tenantId
  711. }
  712. obj = tempObj
  713. return
  714. }
  715. })
  716. console.log(obj, 'obj');
  717. const locationFlag = tt.getStorageSync('locationFlag');
  718. if (locationFlag) {
  719. that.bindPickerChange('', obj.index, obj.tenantId)
  720. tt.setStorageSync('locationFlag', false);
  721. } else {
  722. that.bindPickerChange('', tt.getStorageSync('mallIndex'), tt.getStorageSync('mallTenantId'))
  723. }
  724. },
  725. complete: finish => {
  726. }
  727. })
  728. },
  729. /**
  730. * @description:根据经纬度计算距离
  731. * @param {*} locationInfo (lat1, lng1, lat2, lng2)
  732. * @return: distanceObj: { distance , distance_str }
  733. */
  734. getDistances(lat1, lng1, lat2, lng2) {
  735. function rad(num) {
  736. return num * Math.PI / 180.0;
  737. }
  738. var radLat1 = rad(lat1);
  739. var radLat2 = rad(lat2);
  740. var a = radLat1 - radLat2;
  741. var b = rad(lng1) - rad(lng2);
  742. var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
  743. Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
  744. s = s * 6378.137;
  745. s = Math.round(s * 10000) / 10000;
  746. var distance = s;
  747. var distance_str = "";
  748. if (parseInt(distance) >= 1) {
  749. distance_str = distance.toFixed(2) + "km";
  750. } else if (!arseInt(distance)) {
  751. return false
  752. } else {
  753. distance_str = (distance * 1000).toFixed(2) + "m";
  754. }
  755. let objData = {
  756. distance: distance,
  757. distance_str: distance_str
  758. }
  759. return objData
  760. },
  761. bloob(arr) {
  762. const tempArr = arr
  763. for (let i = 0; i < tempArr.length - 1; i++) {
  764. for (let j = 0; j < tempArr.length - 1 - i; j++) {
  765. if (tempArr[j] > tempArr[j + 1]) {
  766. let temp = tempArr[j];
  767. tempArr[j] = tempArr[j + 1];
  768. tempArr[j + 1] = temp;
  769. }
  770. }
  771. }
  772. return tempArr
  773. },
  774. onShow: function () {
  775. this.mallSync()
  776. console.log(app.globalData.mouldType, "mouldType")
  777. // tt.requestSubscribeMessage({
  778. // tmplIds: [], // 需要填入开放平台申请的模版id,支持最多3个同类型模版
  779. // success(res) {
  780. // //订阅成功
  781. // console.log("订阅成功", res);
  782. // },
  783. // fail(error) {
  784. // //订阅失败
  785. // console.log("订阅失败, 错误详情: ", error);
  786. // tt.showToast({
  787. // title: "订阅失败",
  788. // icon: "fail",
  789. // });
  790. // },
  791. // complete(res) {
  792. // //订阅完成
  793. // console.log("tt.requestSubscribeMessage API调用完成: ", res);
  794. // },
  795. // });
  796. this.setData({
  797. mouldType: app.globalData.mouldType,
  798. marketName: app.globalData.marketName,
  799. activeColor: app.globalData.mouldType == 1 ? "#E9D0AA" : bgColor.colorFirst.main.activeColor
  800. })
  801. // this.uesrInfo()
  802. this.ifShowSqare();
  803. if (tt.getStorageSync("squareList") && tt.getStorageSync("selectedMall")) {
  804. // var temp = tt.getStorageSync("squareList").filter(item => item.tenantId == tt.getStorageSync("selectedMall"))[0].name
  805. // this.setData({
  806. // squareName: temp
  807. // })
  808. }
  809. if (typeof this.getTabBar === 'function' &&
  810. this.getTabBar()) {
  811. this.getTabBar().setData({
  812. selected: 0,
  813. })
  814. }
  815. let that = this;
  816. that.setData({
  817. havePlayEd: app.globalData.havePlayEd ? app.globalData.havePlayEd : false,
  818. havePlayEd1: app.globalData.havePlayEd1 ? app.globalData.havePlayEd1 : false
  819. })
  820. /**
  821. * couponNum 是否有普通的优惠券购买
  822. * couponNum2 是否有新买的消费卡
  823. */
  824. let num = tt.getStorageSync('couponNum');
  825. let num1 = tt.getStorageSync('couponNum2');
  826. // if (num == 'couponNum' || num1 == 'couponNum2') {
  827. // tt.showTabBarRedDot({
  828. // index: 3
  829. // })
  830. // } else {
  831. // tt.hideTabBarRedDot({
  832. // index: 3
  833. // })
  834. // }
  835. if (app.globalData.score) {
  836. that.setData({
  837. fistLogin: app.globalData.score
  838. })
  839. }
  840. // 如果有游戏
  841. setTimeout(function () {
  842. that.alphaClick();
  843. }, 8000)
  844. // 如果有广告
  845. setTimeout(function () {
  846. that.alphaClick1();
  847. }, 8000)
  848. setTimeout(() => {
  849. that.getBannerlist();
  850. that.getBusinessList()
  851. that.setData({
  852. noDataFlag: false
  853. })
  854. that.getCouponChannelList(that.data.businessKey)
  855. }, 1000)
  856. },
  857. getmemberId: function (token) {
  858. let that = this;
  859. Http.get({
  860. url: config.api.getScore,
  861. data: {
  862. token: token
  863. }
  864. }).then(res => {
  865. if (res.data.avatarUrl || res.data.nickName) {
  866. app.globalData.avatarUrl = res.data.avatarUrl
  867. app.globalData.nickName = res.data.nickName
  868. }
  869. that.setData({
  870. levelName: res.data.levelName,
  871. upgradePercent: res.data.upgradePercent,
  872. upgradeScore: res.data.upgradeScore,
  873. memberId: res.data.id,
  874. credit: res.data.credit,
  875. userAvatarUrl: res.data.avatarUrl ? res.data.avatarUrl : '',
  876. userName: res.data.nickName ? res.data.nickName : '',
  877. })
  878. })
  879. .catch(err => {
  880. tt.showModal({
  881. title: '提示',
  882. content: err.message,
  883. showCancel: false
  884. })
  885. })
  886. },
  887. gotoChengzhangzhi: function () {
  888. tt.navigateTo({
  889. url: '/pages/czdetail/czdetail',
  890. })
  891. },
  892. goIntegralmall() {
  893. tt.navigateTo({
  894. url: '/pages/integralmall/index',
  895. })
  896. },
  897. gotoBargain: function () {
  898. tt.navigateTo({
  899. url: '/pages/bargain/bargain',
  900. })
  901. },
  902. gotoSpellGroup: function () {
  903. tt.navigateTo({
  904. url: '/pages/spellGroup/spellGroup',
  905. })
  906. },
  907. gotoCard: function () {
  908. tt.navigateTo({
  909. url: '/pages/discountCardList/discountCardList',
  910. })
  911. },
  912. // gotoGame: function () {
  913. // tt.navigateTo({
  914. // url: '/pages/game/index',
  915. // })
  916. // },
  917. gotoJfsc: function () {
  918. tt.navigateTo({
  919. url: '/pages/integralmall/index',
  920. })
  921. },
  922. /**
  923. *
  924. * @param {code,page}
  925. * 子组件向父组件传值
  926. */
  927. onGetCode: function (e) {
  928. this.setData({
  929. code: e.detail.val,
  930. page: e.detail.pageNum,
  931. });
  932. console.log(e.detail.val)
  933. console.log(e.detail.pageNum)
  934. },
  935. getWeapNote: function (couponChannelId, couponId, orderId) {
  936. var that = this;
  937. if (app.globalData.token) {
  938. that.getsubMallList()
  939. // 登录
  940. console.log(app.globalData.token)
  941. that.getCongig() //获取小程序是否开通授权手机号
  942. that.setData({
  943. mouldType: app.globalData.mouldType,
  944. marketName: app.globalData.marketName,
  945. activeColor: app.globalData.mouldType == 1 ? "#E9D0AA" : bgColor.colorFirst.main.activeColor
  946. })
  947. //获取首页按钮 抖音暂时屏蔽
  948. // that.getModule()
  949. that.getmemberId(app.globalData.token);
  950. that.getBannerlist();
  951. // if (that.data.mouldType == 0) { //富茂原版
  952. // that.topicShow();
  953. // that.getxsList();
  954. // } else if (that.data.mouldType == 1) { //欢乐城模板
  955. // }
  956. that.getShowList()
  957. that.topicShowall(2);
  958. that.topicShowall(3);
  959. that.topicShowall(4);
  960. that.topicShowall(5);
  961. that.topicShowall(6);
  962. that.getBusinessList();
  963. that.getCouponChannelList(0)
  964. that.getsubMallList()
  965. that.getType()
  966. that.uesrInfo()
  967. // that.getLocation();
  968. that.getMallInfo(app.globalData.token);
  969. if (app.couponChannelListCallback) {
  970. app.couponChannelListCallback(app.globalData.token);
  971. }
  972. if (app.couponListCallback) {
  973. app.couponListCallback(app.globalData.token);
  974. }
  975. if (app.businessListCallback) {
  976. app.businessListCallback(app.globalData.token);
  977. }
  978. Http.get({
  979. url: config.api.getWeapNote,
  980. data: {
  981. appId: app.globalData.appId,
  982. }
  983. })
  984. .then(res => {
  985. console.log(33333333333)
  986. console.log(app.globalData.token)
  987. console.log(res)
  988. console.log(33333333333)
  989. // that.getGameOne(app.globalData.token)
  990. // that.getStaticGame(app.globalData.token)
  991. that.getGg(app.globalData.token)
  992. let weapNote = JSON.parse(res.data.weapNote);
  993. that.setData({
  994. // desc: weapNote.firstpage.desc?weapNote.firstpage.desc:"",
  995. // title: weapNote.firstpage.title?weapNote.firstpage.title:'',
  996. })
  997. })
  998. .catch(err => {
  999. // that.getGameOne(app.globalData.token)
  1000. // that.getStaticGame(app.globalData.token)
  1001. that.getGg(app.globalData.token)
  1002. tt.showModal({
  1003. title: "提示",
  1004. content: err.message,
  1005. showCancel: false
  1006. });
  1007. });
  1008. } else {
  1009. app.tokenCallback = token => {
  1010. that.getsubMallList()
  1011. // 登录
  1012. console.log(app.globalData.token)
  1013. that.getCongig() //获取小程序是否开通授权手机号
  1014. that.setData({
  1015. mouldType: app.globalData.mouldType,
  1016. marketName: app.globalData.marketName,
  1017. activeColor: app.globalData.mouldType == 1 ? "#E9D0AA" : bgColor.colorFirst.main.activeColor
  1018. })
  1019. //获取首页按钮 抖音暂时屏蔽
  1020. // that.getModule()
  1021. that.getmemberId(app.globalData.token);
  1022. that.getBannerlist();
  1023. // if (that.data.mouldType == 0) { //富茂原版
  1024. // that.topicShow();
  1025. // that.getxsList();
  1026. // } else if (that.data.mouldType == 1) { //欢乐城模板
  1027. // }
  1028. that.getShowList()
  1029. that.topicShowall(2);
  1030. that.topicShowall(3);
  1031. that.topicShowall(4);
  1032. that.topicShowall(5);
  1033. that.topicShowall(6);
  1034. that.getBusinessList();
  1035. that.getCouponChannelList(0)
  1036. that.getType()
  1037. that.uesrInfo()
  1038. // that.getLocation();
  1039. that.getMallInfo(app.globalData.token);
  1040. if (app.couponChannelListCallback) {
  1041. app.couponChannelListCallback(app.globalData.token);
  1042. }
  1043. if (app.couponListCallback) {
  1044. app.couponListCallback(app.globalData.token);
  1045. }
  1046. if (app.businessListCallback) {
  1047. app.businessListCallback(app.globalData.token);
  1048. }
  1049. Http.get({
  1050. url: config.api.getWeapNote,
  1051. data: {
  1052. appId: app.globalData.appId,
  1053. }
  1054. })
  1055. .then(res => {
  1056. console.log(33333333333)
  1057. console.log(app.globalData.token)
  1058. console.log(res)
  1059. console.log(33333333333)
  1060. // that.getGameOne(app.globalData.token)
  1061. // that.getStaticGame(app.globalData.token)
  1062. that.getGg(app.globalData.token)
  1063. let weapNote = JSON.parse(res.data.weapNote);
  1064. that.setData({
  1065. // desc: weapNote.firstpage.desc?weapNote.firstpage.desc:"",
  1066. // title: weapNote.firstpage.title?weapNote.firstpage.title:'',
  1067. })
  1068. })
  1069. .catch(err => {
  1070. // that.getGameOne(app.globalData.token)
  1071. // that.getStaticGame(app.globalData.token)
  1072. that.getGg(app.globalData.token)
  1073. tt.showModal({
  1074. title: "提示",
  1075. content: err.message,
  1076. showCancel: false
  1077. });
  1078. });
  1079. }
  1080. }
  1081. },
  1082. getStaticGame(token) {
  1083. let _this = this;
  1084. Http.get({
  1085. url: config.api.getGame,
  1086. data: {
  1087. triggleAction: 2, // 固定入口
  1088. token: token
  1089. }
  1090. }).then(res => {
  1091. if (res.data.id) {
  1092. _this.setData({
  1093. showIf: true,
  1094. newUrl: res.data.imgUrl
  1095. })
  1096. } else {
  1097. _this.setData({
  1098. showIf: false
  1099. })
  1100. }
  1101. _this.setData({
  1102. staticGamedata: res.data
  1103. })
  1104. })
  1105. .catch(err => {
  1106. _this.setData({
  1107. showIf: false
  1108. })
  1109. console.log(err)
  1110. })
  1111. },
  1112. getGameOne: function (token) {
  1113. let _this = this;
  1114. Http.get({
  1115. url: config.api.getGame,
  1116. data: {
  1117. triggleAction: 1, // 登录触发
  1118. token: token
  1119. }
  1120. }).then(res => {
  1121. if (res.data.id) {
  1122. _this.setData({
  1123. showGame: true,
  1124. })
  1125. } else {
  1126. _this.setData({
  1127. showGame: false
  1128. })
  1129. }
  1130. _this.setData({
  1131. gamedata: res.data
  1132. })
  1133. })
  1134. .catch(err => {
  1135. _this.setData({
  1136. showGame: false
  1137. })
  1138. this.alphaClick();
  1139. })
  1140. },
  1141. /**
  1142. * mallinfo
  1143. */
  1144. getMallInfo: function (token) {
  1145. let that = this;
  1146. Http.get({
  1147. url: config.api.getMallInfo,
  1148. data: {
  1149. token: token,
  1150. }
  1151. }).then(res => {
  1152. that.setData({
  1153. liveFlag: res.data.liveSupport,
  1154. weappShareTitle: res.data.weappShareTitle ? res.data.weappShareTitle : null,
  1155. weappShareCoverImg: res.data.weappShareCoverImg ? res.data.weappShareCoverImg : null,
  1156. });
  1157. console.log(that.data.liveFlag, "||||")
  1158. })
  1159. .catch(err => {
  1160. // 不需要错误提示
  1161. });
  1162. },
  1163. //获取限时抢购列表
  1164. getxsList() {
  1165. let that = this;
  1166. Http.get({
  1167. url: config.api.couponChannelList,
  1168. data: {
  1169. pageNum: 1,
  1170. pageSize: 3,
  1171. targetAd: 2
  1172. }
  1173. }).then(res => {
  1174. if (res && res.data.total > 0) {
  1175. that.setData({
  1176. xslist: res.data.list,
  1177. showQg: true
  1178. });
  1179. } else {
  1180. that.setData({
  1181. showQg: false
  1182. })
  1183. }
  1184. })
  1185. .catch(err => {
  1186. console.log(err)
  1187. tt.showToast({
  1188. title: err.message,
  1189. icon: 'none',
  1190. duration: 2000,
  1191. mask: false
  1192. });
  1193. })
  1194. },
  1195. /**
  1196. * banner
  1197. */
  1198. getBannerlist: function () {
  1199. let that = this;
  1200. Http.get({
  1201. url: config.api.bannerlist,
  1202. data: {
  1203. pageNum: 1,
  1204. pageSize: 7,
  1205. plat: 3,
  1206. mallTenantId: tt.getStorageSync('mallTenantId') || that.data.scanInTenantId || ""
  1207. }
  1208. }).then(res => {
  1209. that.getmemberId(app.globalData.token);
  1210. // that.checkUserCarStatus();
  1211. that.setData({
  1212. list: res.data.list
  1213. });
  1214. })
  1215. .catch(err => {
  1216. that.getmemberId(app.globalData.token);
  1217. // that.checkUserCarStatus();
  1218. });
  1219. },
  1220. //获取欢乐城专题
  1221. getShowList() {
  1222. Http.get({
  1223. url: config.api.showList
  1224. }).then(res => {
  1225. let tempData = res.data
  1226. tempData.map(item1 => {
  1227. if (item1.couponList) {
  1228. item1.couponList.map(item2 => {
  1229. if (item2.salePriceStr && item2.salePriceStr.indexOf('.') != -1) {
  1230. let str = item2.salePriceStr.split('.')
  1231. item2.salePriceStrQ = str[0]
  1232. item2.salePriceStrH = str[1]
  1233. }
  1234. })
  1235. }
  1236. })
  1237. this.setData({
  1238. specialLsit: res.data ? res.data : []
  1239. })
  1240. }).catch(err => {
  1241. tt.showToast({
  1242. title: err.message ? err.message : err.data,
  1243. icon: 'none',
  1244. duration: 2000,
  1245. mask: false
  1246. });
  1247. })
  1248. },
  1249. /**
  1250. * topicType=2 限时抢购
  1251. * topicType=3 砍价
  1252. * topicType=4 拼团
  1253. * topicType=5 消费卡
  1254. * topicType=6 积分商城
  1255. */
  1256. topicShowall(topicType) {
  1257. Http.get({
  1258. url: config.api.topicShow,
  1259. data: {
  1260. topicType
  1261. }
  1262. }).then(res => {
  1263. let data = res.data
  1264. if (data.couponList != null && data.couponList.length > 0) {
  1265. data.couponList.map(item => {
  1266. if (item.salePriceStr && item.salePriceStr.indexOf('.') != -1) {
  1267. let str = item.salePriceStr.split('.')
  1268. item.salePriceStrQ = str[0]
  1269. item.salePriceStrH = str[1]
  1270. }
  1271. })
  1272. }
  1273. if (topicType == 2) {
  1274. let tempData = data
  1275. this.setData({
  1276. topicObj2: data
  1277. })
  1278. } else if (topicType == 3) {
  1279. this.setData({
  1280. topicObj3: data
  1281. })
  1282. } else if (topicType == 4) {
  1283. this.setData({
  1284. topicObj4: data
  1285. })
  1286. } else if (topicType == 5) {
  1287. this.setData({
  1288. topicObj5: data
  1289. })
  1290. } else if (topicType == 6) {
  1291. this.setData({
  1292. topicObj6: data
  1293. })
  1294. }
  1295. }).catch(err => {
  1296. tt.showToast({
  1297. title: err.message ? err.message : err.data,
  1298. icon: 'none',
  1299. duration: 2000,
  1300. mask: false
  1301. });
  1302. })
  1303. },
  1304. // 专题显示
  1305. topicShow: function () {
  1306. let that = this;
  1307. Http.get({
  1308. url: config.api.topicShow,
  1309. data: {
  1310. token: app.globalData.token
  1311. }
  1312. }).then(res => {
  1313. if (res && res.data) {
  1314. that.setData({
  1315. name: res.data.name,
  1316. cover: res.data.cover,
  1317. id: res.data.id,
  1318. showTopic: true
  1319. })
  1320. } else {
  1321. that.setData({
  1322. showTopic: false
  1323. })
  1324. }
  1325. })
  1326. .catch(err => {
  1327. console.log(err);
  1328. })
  1329. },
  1330. gotoTopic() {
  1331. tt.navigateTo({
  1332. url: `/pages/topicDetail/index?id=${this.data.id}`
  1333. })
  1334. },
  1335. /**
  1336. * 检查用户是否有车
  1337. */
  1338. // checkUserCarStatus: function() {
  1339. // var that = this;
  1340. // Http.get({
  1341. // url: config.api.userCarCount,
  1342. // data: {}
  1343. // }).then(res => {
  1344. // if (res.data > 0) {
  1345. // // 用户名下有车
  1346. // app.globalData.phone = res.data.phone;
  1347. // app.globalData.supportCar = true;
  1348. // // 共同登录
  1349. // that.userCarLogin();
  1350. // }
  1351. // });
  1352. // },
  1353. /**
  1354. * car共同登录
  1355. */
  1356. // userCarLogin: function() {
  1357. // var that = this;
  1358. // if (!app.globalData.carLogin) {
  1359. // // 共同登录
  1360. // Http.post({
  1361. // url: config.api.carInit,
  1362. // data: {
  1363. // phone: app.globalData.phone
  1364. // }
  1365. // }).then(res => {
  1366. // app.globalData.carLogin = true;
  1367. // app.globalData.parkVendor = res.data.vendor;
  1368. // if (res.data.token != "undefined") {
  1369. // app.globalData.etcpToken = res.data.token;
  1370. // }
  1371. // });
  1372. // }
  1373. // },
  1374. /**
  1375. * 获取用户信息
  1376. */
  1377. // getUserInfo: function() {
  1378. // // 获取用户信息
  1379. // tt.getSetting({
  1380. // success: res => {
  1381. // if (res.authSetting["scope.userInfo"]) {
  1382. // // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
  1383. // tt.getUserInfo({
  1384. // success: res => {
  1385. // // 可以将 res 发送给后台解码出 unionId
  1386. // }
  1387. // });
  1388. // }
  1389. // }
  1390. // });
  1391. // },
  1392. gotoBargain: function () {
  1393. tt.navigateTo({
  1394. url: '/pages/bargain/bargain'
  1395. })
  1396. },
  1397. //限时抢购的详情页面
  1398. gotodetail: function (e) {
  1399. tt.navigateTo({
  1400. url: `/pages/coupon/detail/index?couponChannelId=${e.currentTarget.dataset.couponchannelid
  1401. }&couponId=${e.currentTarget.dataset.couponid}`
  1402. });
  1403. },
  1404. //浮层广告
  1405. getGg: function (token) {
  1406. let that = this
  1407. Http.get({
  1408. url: config.api.getGg,
  1409. data: {
  1410. token: token,
  1411. appId: app.globalData.appId,
  1412. openId: "" // tt.getStorageSync('openId')
  1413. }
  1414. }).then(res => {
  1415. console.log(res)
  1416. if (res.data.id) {
  1417. that.setData({
  1418. showGg: true,
  1419. })
  1420. console.log(that.data.showGg, 1111111111111)
  1421. } else {
  1422. that.setData({
  1423. showGg: false
  1424. })
  1425. // that.getGameOne(app.globalData.token)
  1426. console.log(that.data.showGg, 222222222222222222)
  1427. }
  1428. that.setData({
  1429. ggdata: res.data
  1430. })
  1431. })
  1432. .catch(err => {
  1433. this.setData({
  1434. showGg: false
  1435. })
  1436. // that.getGameOne(app.globalData.token)
  1437. that.alphaClick1();
  1438. })
  1439. },
  1440. /**
  1441. * 刷新
  1442. */
  1443. onPullDownRefresh() {
  1444. tt.showLoading({
  1445. title: "加载中..."
  1446. });
  1447. let that = this;
  1448. // that.setData({
  1449. // topicObj2: null, //欢乐城首页限时抢购
  1450. // topicObj3: null, //欢乐城首页砍价
  1451. // topicObj4: null, //欢乐城首页拼团
  1452. // topicObj5: null, //欢乐城首页消费卡
  1453. // topicObj6: null, //欢乐城首页积分商城
  1454. // specialLsit: null, //专题
  1455. // })
  1456. // // that.getWeapNote();
  1457. that.setData({
  1458. page: 1,
  1459. businePageNum: 1,
  1460. noDataFlag: false
  1461. })
  1462. // if (that.data.optionsData != null && (that.data.optionsData.couponChannelId || that.data.optionsData.orderId)) {
  1463. // that.getWeapNote(that.data.optionsData.couponChannelId, that.data.optionsData.orderId);
  1464. // } else {
  1465. // that.getWeapNote()
  1466. // }
  1467. // if (that.selectComponent("#lists")) {
  1468. // if (that.data.code == 0 || that.data.code == undefined) {
  1469. // that.selectComponent("#lists").getList(0, 1, "refresh");
  1470. // tt.stopPullDownRefresh();
  1471. // } else {
  1472. // that.selectComponent("#lists").getList(that.data.code, 1, "refresh");
  1473. // tt.stopPullDownRefresh();
  1474. // };
  1475. // that.selectComponent("#hot").getList();
  1476. // }
  1477. // // 砍价下拉刷新
  1478. // // that.selectComponent("#bargain").getList();
  1479. // // that.selectComponent("#spellGroup").getList();
  1480. // // that.selectComponent("#rushtobyCard").getList();
  1481. // // 爆款专区下拉刷新
  1482. // that.getxsList();
  1483. // that.topicShow();
  1484. this.getBannerlist();
  1485. this.getBusinessList()
  1486. this.getCouponChannelList(this.data.businessKey)
  1487. setTimeout(() => {
  1488. tt.hideLoading();
  1489. tt.stopPullDownRefresh();
  1490. }, 1600);
  1491. },
  1492. //加载更多
  1493. onReachBottom: function () {
  1494. console.log("我到底了")
  1495. let that = this;
  1496. that.data.page++;
  1497. that.setData({
  1498. page: that.data.page,
  1499. businePageNum: that.data.businePageNum + 1
  1500. });
  1501. console.log("加载更多页数" + that.data.page, );
  1502. console.log("加载更多key" + that.data.code);
  1503. // if (that.data.mouldType == 0) { //富茂源模板
  1504. // //父组件获得子组件的方法
  1505. // //如果code == 0
  1506. // if (that.data.code == 0 || that.data.code == undefined) {
  1507. // that.selectComponent("#lists").getList(0, that.data.page);
  1508. // } else {
  1509. // that.selectComponent("#lists").getList(that.data.code, that.data.page);
  1510. // }
  1511. // } else if (that.data.mouldType == 1) {
  1512. // }
  1513. this.getCouponChannelList(that.data.businessKey)
  1514. },
  1515. // 用户点击右上角分享
  1516. onShareAppMessage: function () {
  1517. app.globalData.previewFlag = true
  1518. return {
  1519. path: "/pages/index/index",
  1520. title: this.data.weappShareTitle,
  1521. imageUrl: this.data.weappShareCoverImg,
  1522. success: function (res) {
  1523. tt.showToast({
  1524. title: "分享成功",
  1525. duration: 1000,
  1526. icon: "success"
  1527. });
  1528. }
  1529. };
  1530. }
  1531. });
  1532. Array.prototype.bubbleSort = function () {
  1533. for (let i = 0; i < this.length - 1; i += 1) {
  1534. for (let j = 0; j < this.length - 1 - i; j += 1) {
  1535. if (this[j] > this[j + 1]) {
  1536. const temp = this[j];
  1537. this[j] = this[j + 1];
  1538. this[j + 1] = temp;
  1539. }
  1540. }
  1541. }
  1542. }