lianghanqiang 4 年 前
コミット
ac449ccaa6
10 ファイル変更111 行追加24 行削除
  1. 10 0
      App.vue
  2. 14 1
      assets/http/api.js
  3. 7 13
      assets/http/service.js
  4. 7 0
      main.js
  5. 30 1
      package-lock.json
  6. 9 0
      pages.json
  7. 23 6
      pages/index/index.vue
  8. 5 0
      pages/mine/mine.vue
  9. 1 1
      store/$u.mixin.js
  10. 5 2
      store/index.js

+ 10 - 0
App.vue

@@ -4,7 +4,17 @@
 			//更新版本
 			this.updateApp()
 		},
+		async onShow() {
+			await this.initPlatformParams();
+		},
 		methods:{
+			async initPlatformParams(){
+				const {ACTIVE_SETTING,PAGE_INTERFACE_SHOW} = (await this.$api.platform.getPlatformParams({
+					keys: 'ACTIVE_SETTING,PAGE_INTERFACE_SHOW'
+				})).data.data;
+				this.$u.vuex('vuex_active_setting', JSON.parse(ACTIVE_SETTING));
+				this.$u.vuex('vuex_page_interface_show', JSON.parse(PAGE_INTERFACE_SHOW));
+			},
 			updateApp(){
 				const updateManager = uni.getUpdateManager();
 				updateManager.onCheckForUpdate(function (res) {

+ 14 - 1
assets/http/api.js

@@ -1,9 +1,20 @@
 import {http} from './service.js'
 
 
+
 //文件上传
 const uploadFile =(p)=> http.upload('blade-resource/oss/endpoint/put-file', {name:'file',filePath:p})
 
+const platform = {
+	getPlatformParams: p => http.get('/app/platformsetting/getPlatformValueByList', {params:p}),
+}
+
+const activity = {
+	getWorksList: p => http.get('/app/active/product/sortList', {params:p}),
+	searchWork: p => http.get('/app/active/product/search', {params:{keyword: p}}),
+	getWorksDetail: id => http.get('/sing_active/activeproductrecord/detail', {params:{id}}),
+}
+
 //微信api
 const wxApp={
 	getOpenId:p => http.get('/wx-app/getOpenId', {params:p}),
@@ -27,5 +38,7 @@ export const api={
 	uploadFile,
 	dict,
 	wxApp,
-	loginUser
+	loginUser,
+	activity,
+	platform
 }

+ 7 - 13
assets/http/service.js

@@ -1,9 +1,9 @@
 import Request from 'luch-request'
 
-let baseURL = 'http://localhost:2366/'
+let baseURL = 'http://192.168.1.91:2888'
 
 let tokenUrl = baseURL +
-	"blade-auth/oauth/token?tenantId=000000&password=21232f297a57a5a743894a0e4a801fc3&username=admin"
+	"/blade-auth/oauth/token?tenantId=000000&password=21232f297a57a5a743894a0e4a801fc3&username=admin"
 
 //获取token
 const getTokenStorage = () => {
@@ -40,24 +40,18 @@ http.interceptors.response.use(async (response) => {
 	/* 请求之后拦截器。可以使用async await 做异步操作  */
 	//toekn过期处理 
 	//200 返回数据成功 0
-	if (response.data.code != 200) {
-		uni.showToast({
-			icon:'none',
-			title:response.data.msg
-		})
-		return Promise.reject(response)
-	}
-	return response.data
+	return response
 }, async (err) => { // 请求错误做点什么
-	if (err.data.code == 401) {
+	console.log(err,1234123);
+	if (err.statusCode == 401) {
 		let {
 			config
 		} = err
 		if (!isRefreshing) {
 			isRefreshing = true
 			let token = uni.getStorageSync('token')
-			let [, res] = await uni.request({
-				url: tokenUrl,
+			let [,res] = await uni.request({
+				url:  tokenUrl,
 				method: 'POST',
 				header: {
 					Authorization: "Basic c2FiZXI6c2FiZXJfc2VjcmV0"

+ 7 - 0
main.js

@@ -26,6 +26,13 @@ Vue.prototype.$api = api
 
 //跳转
 Vue.prototype.$jump = function(url, events) {
+	if(this.$isEmpty(url)){
+		uni.showToast({
+		    title: '暂未开放',
+		    icon: 'none'
+		});
+	}
+	
 	uni.navigateTo({
 		url,
 		events

+ 30 - 1
package-lock.json

@@ -1,8 +1,37 @@
 {
   "name": "activitys-uniapp",
   "version": "1.0.0",
-  "lockfileVersion": 1,
+  "lockfileVersion": 2,
   "requires": true,
+  "packages": {
+    "": {
+      "name": "activitys-uniapp",
+      "version": "1.0.0",
+      "license": "ISC",
+      "dependencies": {
+        "luch-request": "^3.0.7",
+        "uview-ui": "^1.8.4"
+      }
+    },
+    "node_modules/@dcloudio/types": {
+      "version": "2.5.13",
+      "resolved": "https://registry.npmmirror.com/@dcloudio/types/download/@dcloudio/types-2.5.13.tgz",
+      "integrity": "sha1-VNCLDMplKgiEGLr2sS0864rITHA="
+    },
+    "node_modules/luch-request": {
+      "version": "3.0.7",
+      "resolved": "https://registry.nlark.com/luch-request/download/luch-request-3.0.7.tgz",
+      "integrity": "sha1-WJT8PT/2JiKwQshJU8EZLM3q+qU=",
+      "dependencies": {
+        "@dcloudio/types": "^2.0.16"
+      }
+    },
+    "node_modules/uview-ui": {
+      "version": "1.8.4",
+      "resolved": "https://registry.npm.taobao.org/uview-ui/download/uview-ui-1.8.4.tgz",
+      "integrity": "sha1-4yu/I3lCHTGQIuMk4ct7U4fTvUQ="
+    }
+  },
   "dependencies": {
     "@dcloudio/types": {
       "version": "2.5.13",

+ 9 - 0
pages.json

@@ -44,6 +44,15 @@
             }
             
         }
+        ,{
+            "path" : "pages/activity/activityDetail",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "作品详情",
+                "enablePullDownRefresh": false
+            }
+            
+        }
     ],
 	"tabBar": {
 		"color": "#555555",

+ 23 - 6
pages/index/index.vue

@@ -17,13 +17,13 @@
 		</view>
 		<view class="" style="height: 20rpx;background-color: #f8f8f8"></view>
 		<view style="padding: 30rpx 30rpx 0">
-			<u-search placeholder="搜索关键词或编号" height="70" v-model="keyword" :show-action="false"></u-search>
+			<u-search placeholder="搜索关键词或编号" height="70" @search="searchWorks" v-model="keyword" :show-action="false"></u-search>
 		</view>
 		<view class="padding-30">
 			<view class="text-bold" style="font-size: 34rpx;">
 				法护未来 童心同行
 			</view>
-			<view class="card shadow" v-for="(item,index) in 20" :key="index">
+			<view  @click="$jump('/pages/activity/activityDetail?id='+item.id)" class="card shadow" v-for="(item,index) in worksList" :key="item.id">
 				<view v-if="index==0" class="center bg-img rank-tag" style="background-image: url(../../static/icon/ph1.png)">
 					<text>1</text>
 				</view>
@@ -35,18 +35,18 @@
 				</view>
 		
 				<view class="left">
-					<image src="../../static/test/jingcha.jpg" mode=""></image>
+					<image :src="item.imgUrl" mode=""></image>
 				</view>
 				<view class="right">
 					<view class="flex-direction flex">
-						<text class="title">小学生法律小知识</text>
-						<text class="desc text-cut-2">活动初,为在场的家长及孩子播放了视频《被拐走的孩子》。这个视频让人触目</text>
+						<text class="title">{{item.title}}</text>
+						<text class="desc text-cut-2">{{item.content}}</text>
 					</view>
 					<view class="bottom">
 						<view class="flex margin-top-10">
 							<image class="center" style="width: 30rpx;height: 30rpx;" src="../../static/icon/remen.png">
 							</image>
-							<text style="color: #353535;margin-left: 6rpx;font-size:28rpx;">236</text>
+							<text style="color: #353535;margin-left: 6rpx;font-size:28rpx;">{{item.voteCount}}</text>
 						</view>
 						<view class="cu-btn round sm line-base">
 							去助力
@@ -61,8 +61,25 @@
 <script>
 	export default {
 		name: '',
+		async mounted() {
+			await this.initWorksList();
+		},
+		methods :{
+			async initWorksList(){
+				const { defaultActiveId:activeId }= this.$store.state['vuex_active_setting'];
+				this.$api.activity.getWorksList({ activeId }).then(res => {
+						this.worksList = res.data.data;
+					});
+				},
+			searchWorks(value){
+				this.$api.activity.searchWork(value).then(res => {
+					this.worksList = res.data.data;
+				})
+			}
+		},
 		data() {
 			return {
+				worksList: [],
 				swiperList: ['https://guosen-bucket-ldt.obs.cn-south-1.myhuaweicloud.com:443/70c8b355db774f85ab9f8d4f6289df69-banner.jpg'],
 				gridList: [{
 						icon: '/static/grid/jieshao.png',

+ 5 - 0
pages/mine/mine.vue

@@ -103,6 +103,11 @@
 						icon: '/static/mine/zhuli.png',
 						url: '',
 					},
+					{
+						name: '我的作品',
+						icon: '/static/mine/zhuli.png',
+						url: '',
+					},
 					{
 						name: '分割线',
 						icon: '',

+ 1 - 1
store/$u.mixin.js

@@ -2,7 +2,7 @@ import { mapState } from 'vuex'
 import store from "@/store"
 
 // 尝试将用户在根目录中的store/index.js的vuex的state变量,全部加载到全局变量中
-let $uStoreKey = [];
+let $uStoreKey = ['activityId'];
 try{
 	$uStoreKey = store.state ? Object.keys(store.state) : [];
 }catch(e){

+ 5 - 2
store/index.js

@@ -1,6 +1,7 @@
 import Vue from 'vue'
 import Vuex from 'vuex'
 import config from '../assets/http/config.js'
+import { api } from '../assets/http/api.js'
 Vue.use(Vuex)
 
 let lifeData = {};
@@ -13,7 +14,7 @@ try{
 }
 
 // 需要永久存储,且下次APP启动需要取出的,在state中的变量名
-let saveStateKeys = ['vuex_audit','vuex_userId','vuex_phone','vuex_skin','vuex_theme'];
+let saveStateKeys = ['vuex_audit','vuex_userId','vuex_phone','vuex_skin','vuex_theme','vuex_active_setting','vuex_page_interface_show'];
 
 // 保存变量到本地存储中
 const saveLifeData = function(key, value){
@@ -41,7 +42,10 @@ const store = new Vuex.Store({
 		vuex_phone: lifeData.vuex_phone ? lifeData.vuex_phone : null,
 		vuex_skin: lifeData.vuex_skin ? lifeData.vuex_skin : config.themeRed.skin,
 		vuex_theme: lifeData.vuex_theme ? lifeData.vuex_theme : config.themeRed.theme,
+		vuex_page_interface_show: lifeData.vuex_page_interface_show ? lifeData.vuex_page_interface_show :  {},
+		vuex_active_setting: lifeData.vuex_active_setting ? lifeData.vuex_active_setting :  {},
 	},
+
 	mutations: {
 		$uStore(state, payload) {
 			// 判断是否多层级调用,state中为对象存在的情况,诸如user.info.score = 1
@@ -65,5 +69,4 @@ const store = new Vuex.Store({
 		}
 	}
 })
-
 export default store