123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- const CONFIG = require("../config.js");
- const plugin = requirePlugin('fm-plugin')
- const { Parse } = plugin
- module.exports = {
- goNovaURL: (path) => {
- console.log(path);
-
- if (path.indexOf("http") != -1) {
- let p = path.split('?')[1]
- let url = p.substring(p.indexOf('http')).split('&')[0]
- console.log(path);
- wx.navigateTo({
- url: path
- });
- return
- }
- if (path.indexOf("wxapp") != -1) {
- return
- }
- if (path.indexOf("/n") != -1) {
- wx.navigateTo({
- url: path
- });
- return
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- return
- },
- getBlockData: async (data) => {
- let className = ""
- if (data.className || (data.filter && data.filter.className)) {
- className = data.className || data.filter.className
- }
- let filter = data.filter || {}
- if (!data.src || data.src == "list") {
- return data.list
- }
- if (data.src && data.src == "filter" && className) {
- let query = new Parse.Query(className);
- query.equalTo("company", CONFIG.default.company)
-
- console.log(filter.equalTo, data.filter.className)
- let keyArr = Object.keys(filter)
- keyArr.forEach(key => {
- console.log(key)
- filter[key].forEach(f => {
- if (key == 'include') {
- query[key](f.key)
- }
- if (key != 'include') {
- if (f.type == "Boolean" && f.isOpen) {
- query[key](f.key, f.value)
- }
- if ((f.type == 'String' || f.type == 'select') && f.value) {
- query[key](f.key, f.value)
- }
- if (f.type == 'Pointer' && f.value) {
- query[key](f.key, f.value)
- }
- if (f.type == 'Array' && f.value && f.value.length > 0) {
- query[key](f.key, f.value)
- }
- }
- })
- });
- switch (className) {
- case 'Lesson':
- query.ascending('sort')
- break
- case 'Article':
- query.ascending('order')
- break
- case 'RushGoods':
- query.ascending('order')
- break
- case 'ShopStore':
- query.ascending('score')
- break
- default:
- query.ascending('index')
- break
- }
- if (data.limit) {
- query.limit(data.limit)
- }
- let list = await query.find();
- console.log("getBlockData", list);
- return list.map(item => item.toJSON())
- }
- return []
- },
- async checkComponentsDataProperties(comp) {
- console.log(comp.data.options && comp.data.options.data)
- return;
- },
-
-
- goGoodsDetail: (e) => {
-
-
-
-
-
- console.log(e)
- console.log(e.currentTarget.dataset.link, e.currentTarget.dataset.type)
- if (e.currentTarget.dataset.link && e.currentTarget.dataset.type == "video") {
- return
- }
-
- let arr = e.currentTarget.dataset.link.split("=")
- if (!arr[1]) {
- wx.navigateBack()
- }
- console.log(arr[1])
-
- let goodsInfo = new Parse.Query("ShopGoods")
- goodsInfo.equalTo("objectId", arr[1])
- goodsInfo.first().then(res => {
- console.log(res)
- let data = res.toJSON()
- wx.navigateTo({
- url: '/nova-shop/pages/goods_detail/goods_detail',
- events: {
- acceptGoodsDetail: function (goodsInfo) {
- console.log(goodsInfo)
- }
- },
- success: function (res) {
- res.eventChannel.emit('acceptGoodsDetail', {
- data
- })
- }
- });
- })
-
- },
- toStoreDetail: (e) => {
- let userInfo = wx.getStorageSync("userLogin");
- if (userInfo == "") {
- util.loginNow();
- return
- }
- let data = JSON.stringify(e.currentTarget.dataset.item)
- if (!data) {
- wx.navigateBack()
- }
- wx.navigateTo({
- url: '/nova-shop/pages/store/store?data=' + data,
- })
- },
- toArticleDetail: (e) => {
-
-
-
-
-
- wx.navigateTo({
- url: e.currentTarget.dataset.url,
- })
- },
- };
|