index.ts 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. // index.ts
  2. import { api_shopInstruments, api_shopProduct } from "../../api/login";
  3. import { api_getOpenId, api_trackPointLog } from "../../api/new";
  4. import { debounce, formatPrice, formatTime } from "../../utils/util";
  5. // 获取应用实例
  6. const app = getApp<IAppOption>();
  7. // pages/orders/orders.ts
  8. Page({
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. imgList: [
  14. // 'https://oss.dayaedu.com/ktyq/1732585725698.png',
  15. // 'https://oss.dayaedu.com/ktyq/1732519468124.png',
  16. // 'https://oss.dayaedu.com/ktyq/1732519479416.png',
  17. // 'https://oss.dayaedu.com/ktyq/1733110029242.png',
  18. // 'https://oss.dayaedu.com/ktyq/1732519500580.png'
  19. "https://oss.dayaedu.com/ktyq/1733449062928.png",
  20. "https://oss.dayaedu.com/ktyq/1733449075055.png",
  21. "https://oss.dayaedu.com/ktyq/1733449085983.png",
  22. "https://oss.dayaedu.com/ktyq/1733449097054.png",
  23. ],
  24. goodsImgList: [
  25. "https://oss.dayaedu.com/ktyq/1739353790443.png",
  26. "https://oss.dayaedu.com/ktyq/1739353815962.png",
  27. "https://oss.dayaedu.com/ktyq/1739353843494.png",
  28. "https://oss.dayaedu.com/ktyq/03/1772550951364.png",
  29. ],
  30. detailImgList: [
  31. {
  32. url: "https://oss.dayaedu.com/ktyq/1733403675345.png",
  33. text: "合作学校音乐数字课堂公开课",
  34. },
  35. {
  36. url: "https://oss.dayaedu.com/ktyq/1733403707851.png",
  37. text: "音乐课课堂器乐教学",
  38. },
  39. {
  40. url: "https://oss.dayaedu.com/ktyq/1733403725644.png",
  41. text: "学期末汇报演出",
  42. },
  43. ],
  44. serviceShow: true,
  45. scrollTop: 0,
  46. current: 0,
  47. detailCurrent: 0,
  48. autoplay: false,
  49. interval: 5000,
  50. duration: 500,
  51. popupShow: false,
  52. videoHeight: "255px",
  53. list: [] as any,
  54. instrumentList: [] as any,
  55. isOverSaled: false, // 是否所有商品都没有库存
  56. selected: {} as any,
  57. selectInstrumentId: '', // 选中的乐器
  58. selectedInstrument: {} as any,
  59. formatSelectGood: {
  60. typeName: '',
  61. showSalePrice: '', // 显示的现价
  62. originalPrice: 0, // 原价
  63. salePrice: 0, // 现价
  64. discountPrice: '' // 已省
  65. } as any, // 格式化所有选中的数据
  66. opacity: 0,
  67. // showSelectedProduct: false, // 是否显示选中商品值
  68. scrolIntoViewStr: "",
  69. scrolIntoView: "",
  70. scrollDiscount: false, // 是否扣减启
  71. isScrollTT: false,
  72. scrollIntoViewType: false,
  73. headerHeight: 0, // 头部的高度
  74. initialScrollHeight: 0, // 滚动高度
  75. isFromPreviewImage: false,
  76. bannerPlay: false, // 视频是否播放
  77. titleControls: false, // 详情是否显示控制条
  78. liuControls: false, // 详情是否显示控制条
  79. bannerImageloaded: false, // Banner 图片是否加载完成
  80. userTypes: 'teacher', // 用户类型:student | teacher
  81. periodList: [
  82. { label: '7 天', value: '7DAY', disabled: false },
  83. { label: '14 天', value: '14DAY', disabled: false },
  84. { label: '1 个月', value: '1MONTH', disabled: false },
  85. { label: '6 个月', value: '6MONTH', disabled: false },
  86. { label: '1 年', value: '1YEAR', disabled: false }
  87. ],
  88. selectedPeriod: '14DAY', // 选中的期限
  89. showBonusGift: false, // 是否显示额外赠送
  90. },
  91. /**
  92. * 生命周期函数--监听页面加载
  93. */
  94. onLoad() {
  95. // this.onInit()
  96. const wxWindowInfo = wx.getWindowInfo();
  97. this.setData({
  98. videoHeight: (wxWindowInfo.windowWidth / 16) * 9 + "px",
  99. });
  100. // 首页进入页面埋点
  101. this.onHomePageTrackPoint()
  102. },
  103. onHomePageTrackPoint() {
  104. // openId
  105. const openId = wx.getStorageSync("openId")
  106. if(openId) {
  107. this.onTrackPoint({
  108. openId,
  109. elementName: '首页'
  110. })
  111. } else {
  112. wx.login({
  113. success: async (res) => {
  114. await api_getOpenId({
  115. code: res.code,
  116. appId: app.globalData.appId
  117. }).then((res: any) => {
  118. // 存储 openId
  119. const openId = res.data.data
  120. wx.setStorageSync("openId", openId);
  121. this.onTrackPoint({
  122. openId,
  123. elementName: '首页'
  124. })
  125. })
  126. }
  127. })
  128. }
  129. },
  130. onReady() {
  131. const that = this;
  132. wx.createSelectorQuery()
  133. .select("#scroll-header")
  134. .boundingClientRect(function (rect) {
  135. that.setData({
  136. headerHeight: rect.height,
  137. });
  138. })
  139. .exec();
  140. wx.createSelectorQuery()
  141. .select("#scroll-view")
  142. .boundingClientRect(function (rect) {
  143. // console.log(rect, 'rect')
  144. that.setData({
  145. initialScrollHeight: rect.height,
  146. });
  147. })
  148. .exec();
  149. },
  150. onBannerVideoLoad() {
  151. this.setData({
  152. bannerImageloaded: true,
  153. });
  154. },
  155. onBannerPlay() {
  156. const bannerVideo = wx.createVideoContext("bannerVideo");
  157. const titleVideo = wx.createVideoContext("titleVideo");
  158. //
  159. this.setData(
  160. {
  161. bannerPlay: true,
  162. },
  163. () => {
  164. bannerVideo.play();
  165. titleVideo.pause();
  166. // liuVideo.stop()
  167. }
  168. );
  169. },
  170. onBannerVideoPlay() {
  171. const titleVideo = wx.createVideoContext("titleVideo");
  172. titleVideo.pause();
  173. // const liuVideo = wx.createVideoContext('liuVideo')
  174. // liuVideo.stop()
  175. },
  176. onTitlePlay() {
  177. const bannerVideo = wx.createVideoContext("bannerVideo");
  178. bannerVideo.pause();
  179. // const liuVideo = wx.createVideoContext('liuVideo')
  180. // liuVideo.stop()
  181. },
  182. onTItleVideoPlay() {
  183. const bannerVideo = wx.createVideoContext("bannerVideo");
  184. const titleVideo = wx.createVideoContext("titleVideo");
  185. // const liuVideo = wx.createVideoContext('liuVideo')
  186. this.setData(
  187. {
  188. titleControls: true,
  189. },
  190. () => {
  191. titleVideo.play();
  192. bannerVideo.pause();
  193. // liuVideo.stop()
  194. }
  195. );
  196. },
  197. onLiuPlay() {
  198. const bannerVideo = wx.createVideoContext("bannerVideo");
  199. bannerVideo.pause();
  200. const titleVideo = wx.createVideoContext("titleVideo");
  201. titleVideo.pause();
  202. },
  203. onLiuVideoPlay() {
  204. const bannerVideo = wx.createVideoContext("bannerVideo");
  205. const titleVideo = wx.createVideoContext("titleVideo");
  206. // const liuVideo = wx.createVideoContext('liuVideo')
  207. bannerVideo.pause();
  208. titleVideo.pause();
  209. this.setData(
  210. {
  211. liuControls: true,
  212. },
  213. () => {
  214. // liuVideo.play()
  215. }
  216. );
  217. },
  218. /**
  219. * 获取基础信息
  220. */
  221. async onInit() {
  222. try {
  223. const result = await api_shopInstruments({ appId: app.globalData.appId })
  224. const instrumentList = result.data.data || []
  225. instrumentList.forEach((item: any) => {
  226. item.showSalePrice = formatPrice(item.salePrice || 0, 'ALL')
  227. item.showOriginalPrice = formatPrice(item.originalPrice || 0, 'ALL')
  228. })
  229. const { data } = await api_shopProduct({ appId: app.globalData.appId });
  230. const list = data.data || [];
  231. let selected: any = {};
  232. let isOverSaled = true; // 是否销售完
  233. list.forEach((item: any) => {
  234. item.originalPrice = formatPrice(item.originalPrice, "ALL");
  235. item.showSalePrice = formatPrice(item.salePrice, "ALL");
  236. item.typeName = this.formatPeriod(item.num, item.period);
  237. item.discountPrice = formatPrice(
  238. item.originalPrice - item.salePrice,
  239. "ALL"
  240. );
  241. const prices: any = formatPrice(item.salePrice);
  242. item.integerPart = prices.integerPart;
  243. item.decimalPart = prices.decimalPart;
  244. // 格式化赠送内容
  245. item.giftLongTime = item.giftFlag
  246. ? this.formatGiftPeriod(item.giftVipDay, item.giftPeriod)
  247. : "";
  248. if (item.stockNum > 0) {
  249. isOverSaled = false;
  250. if (!selected.id) {
  251. selected = item;
  252. }
  253. }
  254. });
  255. if (isOverSaled) {
  256. // 没有可销售商品则默认选中第一个商品
  257. selected = list[0];
  258. }
  259. this.setData({
  260. list,
  261. instrumentList, // 乐器列表
  262. isOverSaled,
  263. selected,
  264. selectInstrumentId: '',
  265. selectedInstrument: {}
  266. }, () => {
  267. this.onFormatGoods()
  268. this.onUpdatePeriodList()
  269. });
  270. } catch (e) {
  271. console.log(e, "e");
  272. }
  273. },
  274. // 格式化类型
  275. formatPeriod(num: number, type: string) {
  276. const template: any = {
  277. DAY: "天卡",
  278. MONTH: "月卡",
  279. YEAR: "年卡",
  280. };
  281. if (type === "YEAR" && num >= 99) {
  282. return "永久卡";
  283. }
  284. return num + template[type];
  285. },
  286. formatGiftPeriod(num: number, type: string) {
  287. if (!num || !type) {
  288. return "";
  289. }
  290. const template: any = {
  291. DAY: "天",
  292. MONTH: "个月",
  293. YEAR: "年",
  294. };
  295. return num + template[type];
  296. },
  297. // 选择
  298. onSelectGoods(e: any) {
  299. const { dataset } = e.currentTarget;
  300. const item = this.data.list.find((item: any) => item.id === dataset.id);
  301. // 判断是否有库存
  302. if (item.stockNum <= 0) {
  303. return;
  304. }
  305. this.setData({
  306. selected: item || {}
  307. }, () => {
  308. this.onFormatGoods()
  309. });
  310. },
  311. /** 选中乐器 */
  312. onSelectInstrument(e: any) {
  313. const { dataset } = e.currentTarget;
  314. if (dataset.id === this.data.selectInstrumentId) {
  315. this.setData({
  316. selectInstrumentId: '',
  317. selectedInstrument: {}
  318. }, () => {
  319. this.onFormatGoods()
  320. })
  321. } else {
  322. const item = this.data.instrumentList.find((item: any) => item.id === dataset.id);
  323. this.setData({
  324. selectInstrumentId: dataset.id,
  325. selectedInstrument: item || {}
  326. }, () => {
  327. this.onFormatGoods()
  328. })
  329. }
  330. },
  331. /** 格式化选中的商品 */
  332. onFormatGoods() {
  333. const selected = this.data.selected;
  334. const selectedInstrument = this.data.selectedInstrument
  335. const params = {
  336. typeName: '',
  337. showSalePrice: '' as any, // 显示的现价
  338. originalPrice: 0, // 原价
  339. salePrice: 0, // 现价
  340. discountPrice: '' as any, // 已省
  341. integerPart: '',
  342. decimalPart: '',
  343. }
  344. // 选中期限
  345. if (selected.id) {
  346. params.typeName = selected.typeName
  347. params.showSalePrice = selected.showSalePrice
  348. params.originalPrice = selected.originalPrice
  349. params.salePrice = selected.salePrice
  350. params.discountPrice = selected.discountPrice
  351. const prices: any = formatPrice(params.salePrice);
  352. params.integerPart = prices.integerPart
  353. params.decimalPart = prices.decimalPart
  354. }
  355. // 选中乐器
  356. if (selectedInstrument.id) {
  357. params.typeName = selected.typeName ? selected.typeName + '+' + selectedInstrument.name : selectedInstrument.name
  358. params.originalPrice = Number(selected.originalPrice) + Number(selectedInstrument.originalPrice)
  359. params.salePrice = Number(selected.salePrice) + Number(selectedInstrument.salePrice)
  360. params.showSalePrice = formatPrice(params.salePrice, "ALL");
  361. params.discountPrice = formatPrice(
  362. params.originalPrice - params.salePrice,
  363. "ALL"
  364. );
  365. const prices: any = formatPrice(params.salePrice);
  366. params.integerPart = prices.integerPart
  367. params.decimalPart = prices.decimalPart
  368. }
  369. this.setData({
  370. formatSelectGood: params
  371. })
  372. },
  373. // 事件处理函数
  374. changeSwiper(e: any) {
  375. const detail = e.detail;
  376. if (detail.source === "touch" || detail.source == "autoplay") {
  377. this.setData({
  378. current: detail.current,
  379. });
  380. this.onTitlePlay();
  381. }
  382. },
  383. changeSwiperDetail(e: any) {
  384. const detail = e.detail;
  385. if (detail.source === "touch" || detail.source == "autoplay") {
  386. this.setData({
  387. detailCurrent: detail.current,
  388. });
  389. }
  390. },
  391. isLogin() {
  392. // 判断是否登录
  393. if (!app.globalData.isLogin) {
  394. wx.navigateTo({
  395. url: "../login/login",
  396. });
  397. return false;
  398. }
  399. return true;
  400. },
  401. /** 我的订单 */
  402. onOrder() {
  403. // 判断是否登录
  404. if (!this.isLogin()) {
  405. return;
  406. }
  407. wx.navigateTo({
  408. url: "../orders/orders",
  409. });
  410. },
  411. onBuyShop() {
  412. // 判断是否登录
  413. if (!this.isLogin()) {
  414. return;
  415. }
  416. this.setData({
  417. popupShow: true,
  418. // showSelectedProduct: true,
  419. });
  420. },
  421. /** 切换学生端/老师端 */
  422. onSwitchUserType(e: any) {
  423. const { dataset } = e.currentTarget;
  424. this.setData({
  425. userTypes: dataset.type
  426. }, () => {
  427. // 这里可以根据用户类型重新加载商品数据
  428. // 目前先保持逻辑不变,后续可根据后端 API 扩展
  429. this.onInit()
  430. })
  431. },
  432. /** 选择期限 */
  433. onSelectPeriod(e: any) {
  434. const { value } = e.currentTarget.dataset
  435. const periodItem = this.data.periodList.find((item: any) => item.value === value)
  436. if (periodItem?.disabled) {
  437. return
  438. }
  439. this.setData({
  440. selectedPeriod: value
  441. }, () => {
  442. // 根据选中的期限更新商品
  443. this.onUpdatePeriodList()
  444. })
  445. },
  446. /** 根据期限更新商品列表 */
  447. onUpdatePeriodList() {
  448. const { selectedPeriod, list } = this.data
  449. // 将期限值映射回商品列表的筛选逻辑
  450. // 这里需要根据实际的 period 和 num 来匹配
  451. const periodMap: any = {
  452. '7DAY': { period: 'DAY', num: 7 },
  453. '14DAY': { period: 'DAY', num: 14 },
  454. '1MONTH': { period: 'MONTH', num: 1 },
  455. '6MONTH': { period: 'MONTH', num: 6 },
  456. '1YEAR': { period: 'YEAR', num: 1 }
  457. }
  458. const target = periodMap[selectedPeriod]
  459. if (target) {
  460. const selectedItem = list.find((item: any) =>
  461. item.period === target.period && item.num === target.num
  462. )
  463. if (selectedItem && selectedItem.stockNum > 0) {
  464. this.setData({
  465. selected: selectedItem
  466. }, () => {
  467. this.onFormatGoods()
  468. })
  469. }
  470. }
  471. // 判断是否满 1 年,显示赠送提示
  472. const showBonusGift = selectedPeriod === '1YEAR'
  473. this.setData({
  474. showBonusGift
  475. })
  476. },
  477. // 进行埋点
  478. onTrackPoint(options: { openId: string, elementName: string }) {
  479. const traceId = wx.getStorageSync("traceId");
  480. const deviceInfo = wx.getDeviceInfo();
  481. api_trackPointLog({
  482. traceId,
  483. openId: options.openId,
  484. elementName: options.elementName,
  485. deviceInfo: deviceInfo.brand + '_' + deviceInfo.model + '_' + deviceInfo.system + '_' + deviceInfo.platform,
  486. appName: "音乐数字 AI",
  487. // extParams: '',
  488. clickTime: formatTime(new Date(), '-') // 点击时间
  489. })
  490. },
  491. onClose() {
  492. this.setData({
  493. popupShow: false,
  494. });
  495. },
  496. onSubmit() {
  497. // 判断是否登录
  498. const that = this;
  499. debounce(function () {
  500. if (!that.isLogin()) {
  501. return;
  502. }
  503. const params = [] as any
  504. const selected = that.data.selected
  505. if (selected.id) {
  506. params.push({
  507. pic: selected.pic,
  508. name: selected.name,
  509. originalPrice: selected.originalPrice,
  510. salePrice: selected.salePrice,
  511. shopId: selected.shopId,
  512. id: selected.id,
  513. goodsType: 'ACTIVATION_CODE', // INSTRUMENTS
  514. })
  515. }
  516. const selectedInstrument = that.data.selectedInstrument
  517. if (selectedInstrument.id) {
  518. params.push({
  519. pic: selectedInstrument.pic,
  520. name: selectedInstrument.name,
  521. originalPrice: selectedInstrument.originalPrice,
  522. salePrice: selectedInstrument.salePrice,
  523. shopId: selectedInstrument.shopId,
  524. id: selectedInstrument.id,
  525. goodsType: 'INSTRUMENTS', // INSTRUMENTS
  526. })
  527. }
  528. // openId
  529. const openId = wx.getStorageSync("openId")
  530. that.onTrackPoint({
  531. openId,
  532. elementName: "立即购买"
  533. })
  534. let info = JSON.stringify({
  535. ...params
  536. });
  537. info = encodeURIComponent(info);
  538. wx.navigateTo({
  539. url: `../orders/order-detail?orderInfo=${info}`,
  540. success: () => {
  541. that.setData({
  542. popupShow: false,
  543. });
  544. },
  545. });
  546. }, 200)();
  547. },
  548. onPreivewBannerImg(e: { currentTarget: { dataset: any } }) {
  549. wx.previewImage({
  550. current: e.currentTarget.dataset.src,
  551. urls: this.data.imgList,
  552. success: () => {
  553. this.setData({
  554. isFromPreviewImage: true,
  555. });
  556. },
  557. });
  558. },
  559. onPreivewDetailImg(e: { currentTarget: { dataset: any } }) {
  560. wx.previewImage({
  561. current: e.currentTarget.dataset.src,
  562. urls: [
  563. "https://oss.dayaedu.com/ktyq/1733403675345.png",
  564. "https://oss.dayaedu.com/ktyq/1733403707851.png",
  565. "https://oss.dayaedu.com/ktyq/1733403725644.png",
  566. ],
  567. success: () => {
  568. this.setData({
  569. isFromPreviewImage: true,
  570. });
  571. },
  572. });
  573. },
  574. onPreivewDetailImg2(e: { currentTarget: { dataset: any } }) {
  575. wx.previewImage({
  576. current: e.currentTarget.dataset.src,
  577. urls: [
  578. "https://oss.dayaedu.com/ktyq/03/1772461866051.png",
  579. ],
  580. success: () => {
  581. this.setData({
  582. isFromPreviewImage: true,
  583. });
  584. },
  585. });
  586. },
  587. onPreivewGoodsImg(e: { currentTarget: { dataset: any } }) {
  588. wx.previewImage({
  589. current: e.currentTarget.dataset.src,
  590. urls: this.data.goodsImgList,
  591. success: () => {
  592. this.setData({
  593. isFromPreviewImage: true,
  594. });
  595. },
  596. });
  597. },
  598. onPreivewGoods(e: { currentTarget: { dataset: any } }) {
  599. wx.previewImage({
  600. current: e.currentTarget.dataset.src,
  601. urls: [e.currentTarget.dataset.src],
  602. success: () => {
  603. this.setData({
  604. isFromPreviewImage: true,
  605. });
  606. },
  607. });
  608. },
  609. /**
  610. * 生命周期函数--监听页面显示
  611. */
  612. onShow() {
  613. if (!this.data.isFromPreviewImage) {
  614. this.onInit();
  615. } else {
  616. this.setData({
  617. isFromPreviewImage: false,
  618. });
  619. }
  620. this.setData({
  621. serviceShow: true,
  622. });
  623. },
  624. onHide() {
  625. this.setData({
  626. serviceShow: false,
  627. });
  628. },
  629. // 页面滚动时颜色变化
  630. onScrollView(e: { detail: any }) {
  631. const top = e.detail.scrollTop || 0;
  632. // const scrollHeight = e.detail.scrollHeight || 0;
  633. // 从 100 开始显示
  634. this.setData({
  635. // opacity: top < 100 ? 0 : (top - 100) > 150 ? 1 : (top - 100) / 150
  636. opacity: top < 100 ? 0 : top - 100 > 150 ? 1 : 1,
  637. });
  638. // if (top + this.data.initialScrollHeight >= scrollHeight - 80) {
  639. // // console.log('已经滑动到底部了');
  640. // // 相应业务逻辑处理
  641. // this.setData({
  642. // scrolIntoViewStr: "type2",
  643. // });
  644. // } else {
  645. // console.log(this.data.scrollDiscount, top, this.data.headerHeight, "top");
  646. if (this.data.scrollIntoViewType) {
  647. this.setData({
  648. scrollTop: this.data.scrollDiscount
  649. ? top - this.data.headerHeight
  650. : top,
  651. scrollIntoViewType: false,
  652. scrollDiscount: false,
  653. isScrollTT: true,
  654. });
  655. } else {
  656. if (!this.data.isScrollTT) {
  657. this.onChangeScroll();
  658. } else {
  659. this.setData({
  660. isScrollTT: false,
  661. });
  662. }
  663. }
  664. // }
  665. },
  666. onChangeScroll() {
  667. const that = this;
  668. debounce(function () {
  669. wx.createSelectorQuery()
  670. .select("#type3")
  671. .boundingClientRect(function (rect) {
  672. let check = false;
  673. if (rect.top > 0 && rect.top <= that.data.headerHeight) {
  674. that.setData({
  675. scrolIntoViewStr: "type3",
  676. });
  677. check = true;
  678. }
  679. if (rect.top > 0 && rect.top > that.data.headerHeight) {
  680. that.setData({
  681. scrolIntoViewStr: "type1",
  682. });
  683. check = true;
  684. }
  685. // console.log('checked', check)
  686. if (!check) {
  687. wx.createSelectorQuery()
  688. .select("#type2")
  689. .boundingClientRect(function (rect) {
  690. if (rect.top > 0 && rect.top <= that.data.headerHeight) {
  691. that.setData({
  692. scrolIntoViewStr: "type2",
  693. });
  694. }
  695. if (rect.top > 0 && rect.top > that.data.headerHeight) {
  696. that.setData({
  697. scrolIntoViewStr: "type3",
  698. });
  699. }
  700. })
  701. .exec();
  702. }
  703. })
  704. .exec();
  705. }, 100)();
  706. },
  707. onTapAnchor(e: { currentTarget: { dataset: any } }) {
  708. const type = e.currentTarget.dataset.type;
  709. this.setData({
  710. scrolIntoView: type,
  711. scrolIntoViewStr: type,
  712. scrollDiscount: true, // type !== 'type2' ? true : false,
  713. scrollIntoViewType: true,
  714. });
  715. },
  716. onShareAppMessage() {
  717. return {
  718. title: "音乐数字 AI",
  719. path: "/pages/index/index",
  720. imageUrl: "https://oss.dayaedu.com/ktyq/1739870592907.png",
  721. };
  722. },
  723. onShareTimeline() {
  724. return {
  725. title: "音乐数字 AI",
  726. path: "/pages/index/index",
  727. imageUrl: "https://oss.dayaedu.com/ktyq/1739870592907.png",
  728. };
  729. },
  730. });