该代码是一个使用了webpack打包工具的小程序页面的JavaScript代码。其中包含了页面的一些生命周期函数,如onLoad、onShow、destroyed等,以及一些自定义的方法,如init、getStoreup等。该页面主要实现了单词本详情的展示、收藏、评论、审核等功能,并使用了mescroll-uni插件实现了下拉刷新和上拉加载更多的功能。该代码还包含了一些ES6的语法,如箭头函数、模板字符串、解构赋值等。

(global['webpackJsonp'] = global['webpackJsonp'] || []).push([['pages/danciben/detail'], {'048a': function(t, e, n) { 'use strict'; (function(t) { n('b3d6'); a(n('66fd')); var e = a(n('e008')); function a(t) { return t && t.__esModule ? t : { default: t } } t(e.default) }).call(this, n('543d')['createPage']) }, '32ac': function(t, e, n) { 'use strict'; n.r(e); var a = n('b4dc'), r = n.n(a); for (var s in a) 'default' !== s && function(t) { n.d(e, t, (function() { return a[t] })) }(s); e['default'] = r.a }, '3f13': function(t, e, n) { }, 'ac6b': function(t, e, n) { 'use strict'; n.d(e, 'b', (function() { return r })), n.d(e, 'c', (function() { return s })), n.d(e, 'a', (function() { return a })); var a = { mescrollUni: function() { return Promise.all([n.e('common/vendor'), n.e('components/mescroll-uni/mescroll-uni')]).then(n.bind(null, '1729')) }, uniPopup: function() { return n.e('components/uni-popup/uni-popup').then(n.bind(null, '9fa2')) } }, r = function() { var t = this, e = t.$createElement, n = (t._self._c, t.isAuth('danciben', '加入')), a = t.isAuthFront('danciben', '加入'); t.$mp.data = Object.assign({}, { $root: { m0: n, m1: a } }) }, s = [] }, 'b4dc': function(t, e, n) { 'use strict'; (function(t) { Object.defineProperty(e, '__esModule', { value: !0 }), e.default = void 0; var a = r(n('a34a')); function r(t) { return t && t.__esModule ? t : { default: t } } function s(t, e, n, a, r, s, i) { try { var u = t[s](i), c = u.value } catch (o) { return void n(o) } u.done ? e(c) : Promise.resolve(c).then(a, r) } function i(t) { return function() { var e = this, n = arguments; return new Promise((function(a, r) { var i = t.apply(e, n); function u(t) { s(i, a, r, u, c, 'next', t) } function c(t) { s(i, a, r, u, c, 'throw', t) } u(void 0) })) } } var u = { data: function() { return { autoplaySwiper: !0, intervalSwiper: 5e3, btnColor: ['#409eff', '#67c23a', '#909399', '#e6a23c', '#f56c6c', '#356c6c', '#351c6c', '#f093a9', '#a7c23a', '#104eff', '#10441f', '#a21233', '#503319'], id: '', userid: '', detail: {}, swiperList: [], commentList: [], mescroll: null, downOption: { auto: !1 }, upOption: { noMoreSize: 3, textNoMore: '~ 没有更多了 ~' }, hasNext: !0, user: {}, sfshIndex: -1, sfshOptions: ['通过', '不通过'], storeupFlag: 0, count: 0, timer: null } }, computed: { baseUrl: function() { return this.$base.url }, SecondToDate: function() { var t = this.count; return null != t && '' != t && (t = t > 60 && t < 3600 ? parseInt(t / 60) + '分钟' + parseInt(60 * (parseFloat(t / 60) - parseInt(t / 60))) + '秒' : t >= 3600 && t < 86400 ? parseInt(t / 3600) + '小时' + parseInt(60 * (parseFloat(t / 3600) - parseInt(t / 3600))) + '分钟' + parseInt(60 * (parseFloat(60 * (parseFloat(t / 3600) - parseInt(t / 3600))) - parseInt(60 * (parseFloat(t / 3600) - parseInt(t / 3600))))) + '秒' : t >= 86400 ? parseInt(t / 3600 / 24) + '天' + parseInt(24 * (parseFloat(t / 3600 / 24) - parseInt(t / 3600 / 24))) + '小时' + parseInt(60 * (parseFloat(t / 3600) - parseInt(t / 3600))) + '分钟' + parseInt(60 * (parseFloat(60 * (parseFloat(t / 3600) - parseInt(t / 3600))) - parseInt(60 * (parseFloat(t / 3600) - parseInt(t / 3600))))) + '秒' : parseInt(t) + '秒'), t } }, onLoad: function(t) { var e = this; return i(a.default.mark((function n() { return a.default.wrap((function(n) { while (1) switch (n.prev = n.next) { case 0: e.id = t.id, t.userid && (e.userid = t.userid); case 2: case 'end': return n.stop() } }), n) })))() }, onShow: function(e) { var n = this; return i(a.default.mark((function e() { var r, s, i; return a.default.wrap((function(e) { while (1) switch (e.prev = e.next) { case 0: return n.init(), r = t.getStorageSync('nowTable'), e.next = 4, n.$api.session(r); case 4: s = e.sent, n.user = s.data, n.btnColor = n.btnColor.sort((function() { return .5 - Math.random() })), n.getStoreup(), i = t.getStorageSync('discussdancibenCleanType'), i && (t.removeStorageSync('discussdancibenCleanType'), n.mescroll.num = 1, n.upCallback(n.mescroll)); case 10: case 'end': return e.stop() } }), e) })))() }, destroyed: function() { }, methods: { onPayTap: function() { t.setStorageSync('paytable', 'danciben'), t.setStorageSync('payObject', this.detail), this.$utils.jump('../pay-confirm/pay-confirm?type=1') }, getStoreup: function() { var t = this; return i(a.default.mark((function e() { var n, r; return a.default.wrap((function(e) { while (1) switch (e.prev = e.next) { case 0: return n = { page: 1, limit: 1, refid: t.id, tablename: 'danciben', userid: t.user.id, type: 1 }, e.next = 3, t.$api.list('storeup', n); case 3: r = e.sent, t.storeupFlag = r.data.list.length; case 5: case 'end': return e.stop() } }), e) })))() }, shoucang: function() { var e = this; return i(a.default.mark((function n() { var r, s, u, c; return a.default.wrap((function(n) { while (1) switch (n.prev = n.next) { case 0: return r = e, s = { page: 1, limit: 1, refid: r.detail.id, tablename: 'danciben', userid: r.user.id, type: 1 }, n.next = 4, r.$api.list('storeup', s); case 4: if (u = n.sent, 1 != u.data.list.length) { n.next = 9; break } return c = u.data.list[0].id, t.showModal({ title: '提示', content: '是否取消', success: function() { var t = i(a.default.mark((function t(e) { return a.default.wrap((function(t) { while (1) switch (t.prev = t.next) { case 0: if (!e.confirm) { t.next = 5; break } return t.next = 3, r.$api.del('storeup', JSON.stringify([c])); case 3: r.$utils.msg('取消成功'), r.getStoreup(); case 5: case 'end': return t.stop() } }), t) }))); function e(e) { return t.apply(this, arguments) } return e() } }), n.abrupt('return'); case 9: t.showModal({ title: '提示', content: '是否收藏', success: function() { var t = i(a.default.mark((function t(e) { return a.default.wrap((function(t) { while (1) switch (t.prev = t.next) { case 0: if (!e.confirm) { t.next = 5; break } return t.next = 3, r.$api.add('storeup', { userid: r.user.id, name: r.detail.dancimingcheng, picture: r.swiperList[0], refid: r.detail.id, tablename: 'danciben' }); case 3: r.$utils.msg('收藏成功'), r.getStoreup(); case 5: case 'end': return t.stop() } }), t) }))); function e(e) { return t.apply(this, arguments) } return e() } }); case 10: case 'end': return n.stop() } }), n) })))() }, onAcrossTap: function(e, n, a, r, s) { if (t.setStorageSync('crossTable', 'danciben'), t.setStorageSync('crossObj', this.detail), t.setStorageSync('statusColumnName', a), t.setStorageSync('statusColumnValue', s), t.setStorageSync('tips', r), '' != a && !a.startsWith('[')) { var i = t.getStorageSync('crossObj'); for (var u in i) if (u == a && i[u] == s) return void this.$utils.msg(r) } this.$utils.jump('../'.concat(e, '/add-or-update?cross=true')) }, init: function() { var t = this; return i(a.default.mark((function e() { var n; return a.default.wrap((function(e) { while (1) switch (e.prev = e.next) { case 0: return e.next = 2, t.$api.info('danciben', t.id); case 2: n = e.sent, t.detail = n.data, t.swiperList = t.detail.dancitupian ? t.detail.dancitupian.split(',') : [], t.detail.dancijiexi = t.detail.dancijiexi.replace(/img src/gi, 'img style='width:100%;' src'); case 6: case 'end': return e.stop() } }), e) })))() }, mescrollInit: function(t) { this.mescroll = t }, downCallback: function(t) { this.hasNext = !0, t.resetUpScroll() }, upCallback: function(t) { var e = this; return i(a.default.mark((function n() { var r; return a.default.wrap((function(n) { while (1) switch (n.prev = n.next) { case 0: return n.next = 2, e.$api.list('discussdanciben', { page: t.num, limit: 10, refid: e.id }); case 2: r = n.sent, 1 == t.num && (e.commentList = []), e.commentList = e.commentList.concat(r.data.list), 0 == r.data.list.length && (e.hasNext = !1), t.endSuccess(t.size, e.hasNext); case 7: case 'end': return n.stop() } }), n) })))() }, onChatTap: function() { this.$utils.jump('../chat/chat') }, download: function(e) { var n = this; e = n.$base.url + e, t.downloadFile({ url: e, success: function(t) { 200 === t.statusCode && (n.$utils.msg('下载成功'), window.open(e)) } }) }, onCartTabTap: function() { this.$utils.tab('../shop-cart/shop-cart') }, onCommentTap: function() { var t = this; return i(a.default.mark((function e() { return a.default.wrap((function(e) { while (1) switch (e.prev = e.next) { case 0: t.$utils.jump('../discussdanciben/add-or-update?refid='.concat(t.id)); case 1: case 'end': return e.stop() } }), e) })))() }, onSHTap: function() { this.$refs.popup.open() }, onFinishTap: function() { var t = this; return i(a.default.mark((function e() { return a.default.wrap((function(e) { while (1) switch (e.prev = e.next) { case 0: if (t.detail.sfsh) { e.next = 3; break } return t.$utils.msg('请选择审核状态'), e.abrupt('return'); case 3: if (t.detail.shhf) { e.next = 6; break } return t.$utils.msg('请填写审核回复'), e.abrupt('return'); case 6: return '通过' == t.detail.sfsh && (t.detail.sfsh = '是'), '不通过' == t.detail.sfsh && (t.detail.sfsh = '否'), e.next = 10, t.$api.update('danciben', t.detail); case 10: t.$utils.msg('审核成功'), t.$refs.popup.close(); case 12: case 'end': return e.stop() } }), e) })))() }, onCloseWinTap: function() { this.$refs.popup.close() }, sfshChange: function(t) { console.log(this.detail), this.sfshIndex = t.target.value, this.detail.sfsh = this.sfshOptions[this.sfshIndex] } } }; e.default = u }).call(this, n('543d')['default']) }, 'd8ca': function(t, e, n) { 'use strict'; var a = n('3f13'), r = n.n(a); r.a }, 'e008': function(t, e, n) { 'use strict'; n.r(e); var a = n('ac6b'), r = n('32ac'); for (var s in r) 'default' !== s && function(t) { n.d(e, t, (function() { return r[t] })) }(s); n('d8ca'); var i, u = n('f0c5'), c = Object(u['a'])(r['default'], a['b'], a['c'], !1, null, null, null, !1, a['a'], i); e['default'] = c.exports }, [['048a', 'common/runtime', 'common/vendor']]]);

该代码实现了一个小程序单词本详情页,可以展示单词本的信息,用户可以收藏、评论、审核单词本。页面还使用了mescroll-uni插件实现下拉刷新和上拉加载更多的功能,方便用户查看评论。代码中使用了ES6语法,例如箭头函数、模板字符串、解构赋值等,使得代码更加简洁易读。

单词本详情页 - 小程序

原文地址: https://www.cveoy.top/t/topic/kFWj 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录