diff --git a/App.vue b/App.vue index 6860b39..96061fa 100644 --- a/App.vue +++ b/App.vue @@ -8,6 +8,7 @@ export default { onLaunch: function() { this.initApp() + // this.$store.commit('initConfig') }, methods: { // 初始化应用 diff --git a/api/system/configList.js b/api/system/configList.js new file mode 100644 index 0000000..1784e0a --- /dev/null +++ b/api/system/configList.js @@ -0,0 +1,12 @@ +// 小程序-配置信息 +import request from '@/utils/request' + +// 小程序-配置信息列表数据查询 +export function getConfigList() { + return request({ + 'url': '/applet/config/configList', + 'method': 'get' + }).then(res => { + return res.data + }) +} \ No newline at end of file diff --git a/api/system/task.js b/api/system/task.js new file mode 100644 index 0000000..d181dbe --- /dev/null +++ b/api/system/task.js @@ -0,0 +1,39 @@ +import request from '@/utils/request' + +// 获取任务列表 +export function getTaskList(data={}){ + return request({ + url: `/h5/task/list`, + headers:{ "isToken":true}, + method: 'get', + params: data + }) +} + +// 接受任务 +export function acceptTask(taskId){ + return request({ + url: `/h5/task/accept/${taskId}`, + headers:{ "isToken":true}, + method: 'post' + }) +} + +// 提交任务 +export function submitTask(data){ + return request({ + url: `/h5/task/submit`, + headers:{ "isToken":true}, + method: 'post', + data + }) +} + +// 获取任务详情 +export function getTaskDetail(taskId){ + return request({ + url: `/h5/task/detail/${taskId}`, + headers:{ "isToken":true}, + method: 'get' + }) +} \ No newline at end of file diff --git a/main.js b/main.js index ce67b75..0cb51bc 100644 --- a/main.js +++ b/main.js @@ -5,10 +5,15 @@ import plugins from './plugins' // plugins import './permission' // permission import share from 'utils/share.js'//share.js import uView from '@/uni_modules/uview-ui' + +import configListMinxin from '@/mixins/configList.js' + Vue.use(uView) Vue.use(plugins) +Vue.mixin(configListMinxin) + Vue.config.productionTip = false Vue.prototype.$store = store diff --git a/mixins/configList.js b/mixins/configList.js new file mode 100644 index 0000000..6b5fcc1 --- /dev/null +++ b/mixins/configList.js @@ -0,0 +1,61 @@ + + +import { mapState } from 'vuex' +export default { + data() { + return { + // 默认的全局分享内容 + Gshare: { + // title: '三只青蛙', + path: '/pages_order/auth/wxLogin', // 全局分享的路径,比如 首页 + // imageUrl: '/static/image/login/logo.png', // 全局分享的图片(可本地可网络) + } + } + }, + computed: { + ...mapState(['configList', 'userInfo', 'riceInfo']), + currentPagePath() { + const pages = getCurrentPages(); + const currentPage = pages[pages.length - 1]; + let path = `/${currentPage.route}`; + + // 获取当前页面的参数 + const options = currentPage.options; + if (options && Object.keys(options).length > 0) { + const params = this.$utils.objectToUrlParams(options); + path += `?${params}`; + } + + return path; + }, + }, + // 定义全局分享 + // 1.发送给朋友 + onShareAppMessage(res) { + let o = { + title : this.configList.logo_name, + ...this.Gshare, + } + if(this.userInfo.id){ + if(this.Gshare.path.includes('?')){ + o.path += '&shareId=' + this.userInfo.id + }else{ + o.path += '?shareId=' + this.userInfo.id + } + } + return o + }, + //2.分享到朋友圈 + onShareTimeline(res) { + let o = { + ...this.Gshare, + title : this.configList.logo_name, + } + if(this.userInfo.id){ + o.path = this.Gshare.path + '?shareId=' + this.userInfo.id + } + return o + }, + methods: { + } +} \ No newline at end of file diff --git a/mixins/list.js b/mixins/list.js new file mode 100644 index 0000000..23bb70e --- /dev/null +++ b/mixins/list.js @@ -0,0 +1,78 @@ +/** + * 处理查询参数 + * @param {Object} self - 组件实例 + * @param {Object} queryParams - 额外的查询参数 + * @returns {Object} 合并后的查询参数 + */ +function query(self, queryParams){ + // 深度合并对象 + return self.$utils.deepMergeObject( + self.$utils.deepMergeObject(self.queryParams, + (self.beforeGetData && self.beforeGetData()) || {}), + queryParams) +} + +/** + * 列表数据加载混入 + * 提供列表数据的加载、分页、下拉刷新、上拉加载更多等功能 + */ +export default { + data() { + return { + queryParams: { + pageNo: 1, + pageSize: 10, + }, + total : 0, + list : [], + } + }, + // 下拉刷新 + onPullDownRefresh() { + this.getData() + }, + // 上拉加载更多 + onReachBottom() { + this.loadMoreData() + }, + // 页面显示时加载数据 + onShow() { + this.getData() + }, + methods: { + /** + * 获取列表数据 + * @param {Object} queryParams - 查询参数 + * @returns {Promise} 返回Promise对象 + */ + getData(queryParams){ + return new Promise((success, error) => { + if(!this.mixinsListApi){ + return console.error('mixinsListApi 缺失'); + } + this.$api(this.mixinsListApi, + query(this, queryParams), res => { + uni.stopPullDownRefresh() + if(res.code == 200){ + success(res.result) + // 更新列表数据 + this[this.mixinsListKey || 'list'] = res.result.records || res.result + // 更新总数 + this.total = res.result.total || res.result.length + // 调用数据加载完成的回调 + this.getDataThen && this.getDataThen(res.result.records, res.result.total, res.result) + } + }) + }) + }, + /** + * 加载更多数据 + */ + loadMoreData(){ + if(this.queryParams.pageSize < this.total){ + this.queryParams.pageSize += 10 + this.getData() + } + }, + } +} \ No newline at end of file diff --git a/pages.json b/pages.json index 2cb8885..baec9dd 100644 --- a/pages.json +++ b/pages.json @@ -149,6 +149,15 @@ "navigationBarTextStyle": "white" } }, + { + "path": "pages/personalCenter/orderDetail", + "style": { + "navigationBarTitleText": "当前订单", + "navigationBarBackgroundColor": "#FFBF60", + "enablePullDownRefresh": false, + "navigationBarTextStyle": "white" + } + }, { "path": "pages/personalCenter/pet", "style": { @@ -292,6 +301,33 @@ "enablePullDownRefresh": false, "navigationBarTextStyle": "white" } + }, + { + "path": "pages/personalCenter/taskList", + "style": { + "navigationBarTitleText": "任务中心", + "navigationBarBackgroundColor": "#FFBF60", + "enablePullDownRefresh": false, + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/personalCenter/taskDetail", + "style": { + "navigationBarTitleText": "任务详情", + "navigationBarBackgroundColor": "#FFBF60", + "enablePullDownRefresh": false, + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/personalCenter/userInfo", + "style": { + "navigationBarTitleText": "个人信息", + "navigationBarBackgroundColor": "#FFBF60", + "enablePullDownRefresh": false, + "navigationBarTextStyle": "white" + } } ], "tabBar": { diff --git a/pages/components/NewUserCoupon.vue b/pages/components/NewUserCoupon.vue new file mode 100644 index 0000000..0174c3a --- /dev/null +++ b/pages/components/NewUserCoupon.vue @@ -0,0 +1,120 @@ + + + + + \ No newline at end of file diff --git a/pages/index.vue b/pages/index.vue index cfaadae..cd5ba52 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -1,6 +1,9 @@