提交 269f457a authored 作者: 劳广强's avatar 劳广强

feat(文章): 文章筛选层级增加一层

上级 9d671fa9
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
"printWidth": 180, "printWidth": 180,
"proseWrap": "preserve", "proseWrap": "preserve",
"quoteProps": "consistent", "quoteProps": "consistent",
"semi": true, "semi": false,
"singleAttributePerLine": false, "singleAttributePerLine": false,
"singleQuote": true, "singleQuote": true,
"tabWidth": 2, "tabWidth": 2,
......
...@@ -2,18 +2,17 @@ ...@@ -2,18 +2,17 @@
export default { export default {
globalData: {}, globalData: {},
onLaunch() { onLaunch() {
console.log('App Launch'); console.log('App Launch')
}, },
onShow() { onShow() {
console.log('App Show'); console.log('App Show')
}, },
onHide() { onHide() {
console.log('App Hide'); console.log('App Hide')
}, },
}; }
</script> </script>
<style> <style>
/*每个页面公共css */ /*每个页面公共css */
</style> </style>
......
...@@ -16,10 +16,10 @@ export default { ...@@ -16,10 +16,10 @@ export default {
}, },
data() { data() {
return {}; return {}
}, },
methods: {}, methods: {},
}; }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<script> <script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
CSS.supports('top: constant(a)'))
document.write( document.write(
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + '<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') + '" />') (coverSupport ? ', viewport-fit=cover' : '') +
'" />'
)
</script> </script>
<script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script> <script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
<script> <script>
// VConsole will be exported to `window.VConsole` by default. // VConsole will be exported to `window.VConsole` by default.
var vConsole = new window.VConsole(); var vConsole = new window.VConsole()
</script> </script>
<title></title> <title></title>
<!--preload-links--> <!--preload-links-->
......
import App from './App'; import App from './App'
// #ifndef VUE3 // #ifndef VUE3
import Vue from 'vue'; import Vue from 'vue'
import uView from '@/uni_modules/uview-ui'; import uView from '@/uni_modules/uview-ui'
import { getPrice } from '@/utils/util'; import { getPrice } from '@/utils/util'
Vue.use(uView);
Vue.config.productionTip = false; Vue.use(uView)
Vue.config.productionTip = false
Array.prototype.at = function (index) { Array.prototype.at = function (index) {
return [...this].splice(index, 1).pop(); return [...this].splice(index, 1).pop()
}; }
Vue.prototype.getPrice = getPrice; Vue.prototype.getPrice = getPrice
App.mpType = 'app'; App.mpType = 'app'
const app = new Vue({ const app = new Vue({
...App, ...App,
}); })
// 引入请求封装,将app参数传递到配置中 // 引入请求封装,将app参数传递到配置中
require('@/utils/request.js')(app); require('@/utils/request.js')(app)
app.$mount(); app.$mount()
// #endif // #endif
// #ifdef VUE3 // #ifdef VUE3
import { createSSRApp } from 'vue'; import { createSSRApp } from 'vue'
export function createApp() { export function createApp() {
const app = createSSRApp(App); const app = createSSRApp(App)
return { return {
app, app,
}; }
} }
// #endif // #endif
{ {
"name" : "荣县随手拍", "name": "荣县随手拍",
"appid" : "__UNI__7F4BF0D", "appid": "__UNI__7F4BF0D",
"description" : "", "description": "",
"versionName" : "1.0.0", "versionName": "1.0.0",
"versionCode" : "100", "versionCode": "100",
"transformPx" : false, "transformPx": false,
/* 5+App特有相关 */ /* 5+App特有相关 */
"app-plus" : { "app-plus": {
"usingComponents" : true, "usingComponents": true,
"nvueStyleCompiler" : "uni-app", "nvueStyleCompiler": "uni-app",
"compilerVersion" : 3, "compilerVersion": 3,
"splashscreen" : { "splashscreen": {
"alwaysShowBeforeRender" : true, "alwaysShowBeforeRender": true,
"waiting" : true, "waiting": true,
"autoclose" : true, "autoclose": true,
"delay" : 0 "delay": 0
}, },
/* 模块配置 */ /* 模块配置 */
"modules" : {}, "modules": {},
/* 应用发布信息 */ /* 应用发布信息 */
"distribute" : { "distribute": {
/* android打包配置 */ /* android打包配置 */
"android" : { "android": {
"permissions" : [ "permissions": [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>", "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>", "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>", "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
...@@ -41,56 +41,57 @@ ...@@ -41,56 +41,57 @@
] ]
}, },
/* ios打包配置 */ /* ios打包配置 */
"ios" : {}, "ios": {},
/* SDK配置 */ /* SDK配置 */
"sdkConfigs" : {} "sdkConfigs": {}
} }
}, },
/* 快应用特有相关 */ /* 快应用特有相关 */
"quickapp" : {}, "quickapp": {},
/* 小程序特有相关 */ /* 小程序特有相关 */
"mp-weixin" : { "mp-weixin": {
"appid" : "", "appid": "",
"setting" : { "setting": {
"urlCheck" : false "urlCheck": false
}, },
"usingComponents" : true "usingComponents": true
}, },
"mp-alipay" : { "mp-alipay": {
"usingComponents" : true "usingComponents": true
}, },
"mp-baidu" : { "mp-baidu": {
"usingComponents" : true "usingComponents": true
}, },
"mp-toutiao" : { "mp-toutiao": {
"usingComponents" : true "usingComponents": true
}, },
"uniStatistics" : { "uniStatistics": {
"enable" : false "enable": false
}, },
"vueVersion" : "2", "vueVersion": "2",
"h5" : { "h5": {
"devServer" : { "devServer": {
"proxy" : { "proxy": {
"/api" : { "/api": {
// "target" : "https://csssptest.yuhuofei.cn", // "target" : "https://csssptest.yuhuofei.cn",
"target" : "https://devrxssph5.yuhuofei.cn/", // "target" : "https://devrxssph5.yuhuofei.cn/",
"pathRewrite" : {} "target": "https://devrxssph5.yuhuofei.cn/",
"pathRewrite": {}
} }
} }
}, },
// "^/api" : "" // "^/api" : ""
"sdkConfigs" : { "sdkConfigs": {
"maps" : { "maps": {
"amap" : { "amap": {
"key" : "8b8fb3d3301c5b625441178cdf23318f", "key": "8b8fb3d3301c5b625441178cdf23318f",
"securityJsCode" : "45882b25dcfbe17d0563ffa223fd1d92", "securityJsCode": "45882b25dcfbe17d0563ffa223fd1d92",
"serviceHost" : "" "serviceHost": ""
} }
} }
}, },
"router" : { "router": {
"base" : "" "base": ""
} }
} }
} }
...@@ -140,7 +140,8 @@ ...@@ -140,7 +140,8 @@
"backgroundColor": "#F8F8F8" "backgroundColor": "#F8F8F8"
}, },
"uniIdRouter": {}, "uniIdRouter": {},
"condition" : { //模式配置,仅开发期间生效 "condition": {
//模式配置,仅开发期间生效
"current": 0, //当前激活的模式(list 的索引项) "current": 0, //当前激活的模式(list 的索引项)
"list": [ "list": [
{ {
......
.wrapper{ .wrapper {
height: 300rpx; height: 300rpx;
padding-top: 50rpx; padding-top: 50rpx;
} }
.oneText{ .oneText {
width: 90%; width: 90%;
padding: 10rpx; padding: 10rpx;
margin: auto; margin: auto;
margin-bottom: 30rpx; margin-bottom: 30rpx;
display: flex; display: flex;
} }
.nameInp{ .nameInp {
width: 100%; width: 100%;
// border: 1px solid #cccc; // border: 1px solid #cccc;
padding: 22rpx 20rpx; padding: 22rpx 20rpx;
...@@ -21,17 +20,17 @@ ...@@ -21,17 +20,17 @@
font-weight: 400; font-weight: 400;
color: #000000; color: #000000;
} }
.nameSpan{ .nameSpan {
width: 34%; width: 34%;
text-align: center; text-align: center;
line-height: 80rpx; line-height: 80rpx;
} }
.cardSpan{ .cardSpan {
width: 34%; width: 34%;
text-align: center; text-align: center;
line-height: 80rpx; line-height: 80rpx;
} }
.cardInp{ .cardInp {
width: 100%; width: 100%;
// border: 1px solid #cccc; // border: 1px solid #cccc;
padding: 22rpx 20rpx; padding: 22rpx 20rpx;
...@@ -41,7 +40,7 @@ ...@@ -41,7 +40,7 @@
font-weight: 400; font-weight: 400;
color: #000000; color: #000000;
} }
.twoText{ .twoText {
width: 90%; width: 90%;
margin: auto; margin: auto;
padding: 10rpx; padding: 10rpx;
...@@ -49,7 +48,7 @@ ...@@ -49,7 +48,7 @@
// border: 1px solid #cccc; // border: 1px solid #cccc;
margin-bottom: 30rpx; margin-bottom: 30rpx;
} }
.cccc{ .cccc {
margin-top: 40rpx; margin-top: 40rpx;
width: 80%; width: 80%;
margin: auto; margin: auto;
...@@ -58,18 +57,18 @@ ...@@ -58,18 +57,18 @@
font-size: 30rpx; font-size: 30rpx;
color: red; color: red;
} }
.postFrom{ .postFrom {
margin-top: 40rpx; margin-top: 40rpx;
width: 93%; width: 93%;
margin: auto; margin: auto;
// margin-bottom: 30rpx; // margin-bottom: 30rpx;
} }
.cccText{ .cccText {
// font-size: 30rpx // font-size: 30rpx
// margin-bottom: 20rpx; // margin-bottom: 20rpx;
} }
.cccBut{ .cccBut {
height: 92rpx; height: 92rpx;
width: 80%; width: 80%;
margin: auto; margin: auto;
...@@ -84,7 +83,7 @@ ...@@ -84,7 +83,7 @@
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.fromBut{ .fromBut {
height: 92rpx; height: 92rpx;
background: linear-gradient(270deg, #8171fc, #a471fc); background: linear-gradient(270deg, #8171fc, #a471fc);
border-radius: 46rpx; border-radius: 46rpx;
......
<template> <template>
<view class="wrapper"> <view class="wrapper">
<view class="oneText"> <view class="oneText"> <span class="nameSpan">姓名:</span><input type="text" class="nameInp" placeholder="请输入姓名" v-model="name" /> </view>
<view class="twoText"> <span class="cardSpan">身份证号:</span><input type="text" class="cardInp" placeholder="请输入身份证号" v-model="card" /> </view>
<span class="nameSpan">姓名:</span><input type="text" class="nameInp" placeholder="请输入姓名" v-model="name">
</view>
<view class="twoText">
<span class="cardSpan">身份证号:</span><input type="text" class="cardInp" placeholder="请输入身份证号" v-model="card">
</view>
<view class="cccc"> <view class="cccc">
<text class="cccText">请使用前置摄头录制一段2~3秒人脸视频,录制完成后上传进行实人认证</text> <text class="cccText">请使用前置摄头录制一段2~3秒人脸视频,录制完成后上传进行实人认证</text>
<button class="cccBut" @click="chooseVideo">{{videoYes ? '重新录制':'录制实人认证视频'}}</button> <button class="cccBut" @click="chooseVideo">{{ videoYes ? '重新录制' : '录制实人认证视频' }}</button>
</view> </view>
<view class="postFrom" v-if="!logNice"> <view class="postFrom" v-if="!logNice">
<button type="primary" class="fromBut" @click="getAuthen">确认提交</button> <button type="primary" class="fromBut" @click="getAuthen">确认提交</button>
...@@ -20,47 +14,47 @@ ...@@ -20,47 +14,47 @@
</view> </view>
<u-modal confirmText="我已知晓" :show="modalShow" @confirm="onModalConfirm"> <u-modal confirmText="我已知晓" :show="modalShow" @confirm="onModalConfirm">
<view class="modal" :style="`max-height: ${modalHeight}rpx; overflow-y: scroll; white-space: pre-wrap`"> <view class="modal" :style="`max-height: ${modalHeight}rpx; overflow-y: scroll; white-space: pre-wrap`">
<u-parse content='1.确保摄像头无遮挡物,录制清晰、稳定的视频。 <u-parse
content="1.确保摄像头无遮挡物,录制清晰、稳定的视频。
2.调整光线:选择明亮、均匀的环境,避免强光或阴影。 2.调整光线:选择明亮、均匀的环境,避免强光或阴影。
3.角度和距离:将摄像设备置于与人脸平行的位置,并保持适当距离。 3.角度和距离:将摄像设备置于与人脸平行的位置,并保持适当距离。
4.简洁背景:选择无干扰的背景,突出人脸。 4.简洁背景:选择无干扰的背景,突出人脸。
5.面部配合:被拍摄者需保持自然面部表情,避免遮挡物。 5.面部配合:被拍摄者需保持自然面部表情,避免遮挡物。
6.确保人脸清晰可见,无噪点或模糊现象。' /> 6.确保人脸清晰可见,无噪点或模糊现象。"
/>
</view> </view>
</u-modal> </u-modal>
</view> </view>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {
name: "", name: '',
card: '', card: '',
videoUrl: {}, videoUrl: {},
videoYes: false, videoYes: false,
Jbool: false, Jbool: false,
logNice: false, logNice: false,
modalShow: false, modalShow: false,
}
};
}, },
computed: { computed: {
modalHeight() { modalHeight() {
// console.log(innerHeight); // console.log(innerHeight);
return Math.ceil(window.innerHeight * 2 * 0.6); return Math.ceil(window.innerHeight * 2 * 0.6)
}, },
}, },
methods: { methods: {
chooseVideo() { chooseVideo() {
// console.log(this.name,this.card); // console.log(this.name,this.card);
if (this.name == '') { if (this.name == '') {
return uni.$u.toast('请输入姓名'); return uni.$u.toast('请输入姓名')
} else if (this.card == '') { } else if (this.card == '') {
return uni.$u.toast('请输入身份证号'); return uni.$u.toast('请输入身份证号')
} }
this.modalShow = true this.modalShow = true
}, },
back() { back() {
uni.navigateBack() uni.navigateBack()
...@@ -72,60 +66,58 @@ ...@@ -72,60 +66,58 @@
compressed: true, compressed: true,
maxDuration: 4, maxDuration: 4,
camera: 'front', camera: 'front',
success: res => { success: (res) => {
// console.log(res.tempFile); // console.log(res.tempFile);
this.videoYes = true this.videoYes = true
this.videoUrl = res.tempFile this.videoUrl = res.tempFile
}, },
fail: e => { fail: (e) => {
console.log(e); console.log(e)
} },
}) })
}, },
getAuthen() { getAuthen() {
uni.showLoading({ uni.showLoading({
title: '加载中' title: '加载中',
}); })
if (this.name == '') { if (this.name == '') {
return uni.$u.toast('请输入姓名'); return uni.$u.toast('请输入姓名')
} else if (this.card == '') { } else if (this.card == '') {
return uni.$u.toast('请输入身份证号'); return uni.$u.toast('请输入身份证号')
} else if (!this.videoYes) { } else if (!this.videoYes) {
return uni.$u.toast('请完成实名验证'); return uni.$u.toast('请完成实名验证')
} }
uni.uploadFile({ uni.uploadFile({
url: "/api/user/real_person_auth", url: '/api/user/real_person_auth',
file: this.videoUrl, file: this.videoUrl,
name: "video", name: 'video',
formData: { formData: {
"name": this.name, name: this.name,
"id_card": this.card //其他表单字段,可根据需求添加 id_card: this.card, //其他表单字段,可根据需求添加
}, },
success: function(res) { success: function (res) {
this.Jbool = false this.Jbool = false
uni.hideLoading() uni.hideLoading()
return uni.$u.toast('实名认证完成'); return uni.$u.toast('实名认证完成')
setTimeout(function() { setTimeout(function () {
uni.navigateTo({ uni.navigateTo({
url:'../index/index' url: '../index/index',
}) })
}, 2000) }, 2000)
// this.logNice = true // this.logNice = true
}, },
fail: function(err) { fail: function (err) {
this.Jbool = false this.Jbool = false
// uni.hideLoading() // uni.hideLoading()
return uni.$u.toast('实名认证失败'); return uni.$u.toast('实名认证失败')
} },
}) })
},
} },
} }
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@import './Authentication.scss'; @import './Authentication.scss';
// @import 'index.scss'; // @import 'index.scss';
</style> </style>
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
</template> </template>
<script> <script>
import { articleDetail } from '@/pages/article-detail/mock'; import { articleDetail } from '@/pages/article-detail/mock'
export default { export default {
data() { data() {
...@@ -73,29 +73,29 @@ export default { ...@@ -73,29 +73,29 @@ export default {
ifshare: true, ifshare: true,
tipPyq: false, // 朋友圈提示 tipPyq: false, // 朋友圈提示
showTip: false, // 分享提示 showTip: false, // 分享提示
}; }
}, },
onLoad(query) { onLoad(query) {
this.query = query; this.query = query
this.fetchArticleDetail(); this.fetchArticleDetail()
}, },
methods: { methods: {
async fetchArticleDetail() { async fetchArticleDetail() {
const token = uni.getStorageSync('token'); const token = uni.getStorageSync('token')
const { detail } = await uni.$u.http.get('/api/article/detail', { params: { id: this.query.id } }); const { detail } = await uni.$u.http.get('/api/article/detail', { params: { id: this.query.id } })
this.articleDetail = detail; this.articleDetail = detail
this.created = detail.created.substring(0, 10); this.created = detail.created.substring(0, 10)
this.title = detail.title; this.title = detail.title
this.follow = detail.follow_status; this.follow = detail.follow_status
this.fabulous = detail.like_status; this.fabulous = detail.like_status
this.likes_num = detail.likes_num; this.likes_num = detail.likes_num
this.content = detail.content; this.content = detail.content
}, },
}, },
}; }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -17,4 +17,4 @@ export const articleDetail = { ...@@ -17,4 +17,4 @@ export const articleDetail = {
}, },
like_status: false, like_status: false,
follow_status: false, follow_status: false,
}; }
...@@ -7,8 +7,14 @@ ...@@ -7,8 +7,14 @@
<view :class="[articleIdx === index ? 'task_line' : 'task_line_none']"></view> <view :class="[articleIdx === index ? 'task_line' : 'task_line_none']"></view>
</view> </view>
</view> </view>
<view class="article_list">
<view class="article_item" v-for="(item, index) in articleDeepTypeList" @click="changeDeepArticle(item, index)" :key="item.name">
<view :class="[articleDeepIdx === index ? 'article_active' : 'article_item_name']">{{ item.name }}</view>
<view :class="[articleDeepIdx === index ? 'task_line' : 'task_line_none']"></view>
</view>
</view>
</view> </view>
<view class="line"></view> <view class="line" />
<view v-if="!articleLoading && !articleList.data.length" class="data_none"> <view v-if="!articleLoading && !articleList.data.length" class="data_none">
<image mode="aspectFill" class="data_img" src="/static/pic_wushuju@2x.png" /> <image mode="aspectFill" class="data_img" src="/static/pic_wushuju@2x.png" />
<view class="data_title">暂无数据</view> <view class="data_title">暂无数据</view>
...@@ -47,8 +53,8 @@ ...@@ -47,8 +53,8 @@
</template> </template>
<script> <script>
import { getList, createList } from '@/utils/list'; import { getList, createList } from '@/utils/list'
import LoadMore from '@/components/LoadMore'; import LoadMore from '@/components/LoadMore'
export default { export default {
components: { LoadMore }, components: { LoadMore },
...@@ -56,35 +62,51 @@ export default { ...@@ -56,35 +62,51 @@ export default {
return { return {
articleTypeList: [], articleTypeList: [],
articleTypeId: 0, articleTypeId: 0,
articleList: createList(),
articleIdx: 0, articleIdx: 0,
articleDeepTypeList: [],
articleDeepTypeId: 0,
articleDeepIdx: 0,
articleList: createList(),
articleLoading: true, articleLoading: true,
id: null, id: null,
ifShare: true, ifShare: true,
is_fabulous: null, // 点赞 is_fabulous: null, // 点赞
is_follow: null, // 关注 is_follow: null, // 关注
}; }
}, },
onLoad(query) { onLoad(query) {
this.fetchArticleTypeData(); this.fetchArticleTypeData()
}, },
onReachBottom() { onReachBottom() {
this.fetchArticleData(); this.fetchArticleData()
}, },
methods: { methods: {
async fetchArticleTypeData() { async fetchArticleTypeData() {
const { list } = await uni.$u.http.get('/api/app/articletype/list'); const { list } = await uni.$u.http.get('/api/app/articletype/list')
this.articleTypeList = list; this.articleTypeList = list
this.articleTypeId = list[0]?.id ?? 0; if (list.length <= 0) return
this.fetchArticleData(); const firstId = list[0]?.id ?? 0
this.fetchArticleDeepTypeData(firstId)
},
async fetchArticleDeepTypeData(id) {
const url = `/api/backend/articletype/list?parent_id=${id}`
const { list } = await uni.$u.http.get(url)
this.articleDeepTypeList = list
if (list.length <= 0) return
this.articleDeepTypeId = list[0]?.id
this.fetchArticleData()
}, },
async fetchArticleData() { async fetchArticleData() {
this.articleLoading = true; this.articleLoading = true
const articleTypeId = this.articleTypeId; const articleTypeId = this.articleTypeId
const articleDeepTypeId = this.articleDeepTypeId
await getList( await getList(
this, this,
...@@ -92,29 +114,38 @@ export default { ...@@ -92,29 +114,38 @@ export default {
[ [
'/api/article/list', '/api/article/list',
{ {
article_type_id: this.articleTypeId, article_type_id: this.articleDeepTypeId,
}, },
], ],
{ {
abandon: () => articleTypeId !== this.articleTypeId, abandon: () => articleTypeId !== this.articleTypeId || articleDeepTypeId !== this.articleDeepTypeId,
} }
); )
this.articleLoading = false; this.articleLoading = false
}, },
async changeArticle(item, index) { async changeArticle(item, index) {
if (this.articleIdx === index) return; if (this.articleIdx === index) return
this.articleIdx = index; this.articleIdx = index
this.articleTypeId = item.id; this.articleTypeId = item.id
this.articleList = createList(); this.articleDeepIdx = 0
this.fetchArticleData(); this.articleList = createList()
this.fetchArticleDeepTypeData(this.articleTypeId)
},
async changeDeepArticle(item, index) {
if (this.articleDeepIdx === index) return
this.articleDeepIdx = index
this.articleDeepTypeId = item.id
this.articleList = createList()
this.fetchArticleData()
}, },
onArticleClick(item, index) { onArticleClick(item, index) {
uni.$u.route({ url: 'pages/article-detail/index', params: { id: item.id } }); uni.$u.route({ url: 'pages/article-detail/index', params: { id: item.id } })
}, },
}, },
}; }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -2,7 +2,7 @@ export const articleSort = [ ...@@ -2,7 +2,7 @@ export const articleSort = [
{ object_name: 'articletype', status: 1, object_type: 'default', name: '\u5927\u57ce\u5c0f\u4e8b', id: 15, weight: 1 }, { object_name: 'articletype', status: 1, object_type: 'default', name: '\u5927\u57ce\u5c0f\u4e8b', id: 15, weight: 1 },
{ object_name: 'articletype', status: 1, object_type: 'default', name: '\u653f\u7b56\u5ba3\u4f20', id: 16, weight: 0 }, { object_name: 'articletype', status: 1, object_type: 'default', name: '\u653f\u7b56\u5ba3\u4f20', id: 16, weight: 0 },
{ object_name: 'articletype', status: 1, object_type: 'default', name: '四个大字', id: 17, weight: 0 }, { object_name: 'articletype', status: 1, object_type: 'default', name: '四个大字', id: 17, weight: 0 },
]; ]
export const articleList = [ export const articleList = [
{ {
...@@ -365,4 +365,4 @@ export const articleList = [ ...@@ -365,4 +365,4 @@ export const articleList = [
get_like_num: 0, get_like_num: 0,
follow_status: false, follow_status: false,
}, },
]; ]
...@@ -131,7 +131,7 @@ page { ...@@ -131,7 +131,7 @@ page {
&-list { &-list {
width: 100%; width: 100%;
padding: 40rpx 0; padding: 20rpx 0;
display: flex; display: flex;
align-items: center; align-items: center;
overflow-x: scroll; overflow-x: scroll;
......
...@@ -44,6 +44,12 @@ ...@@ -44,6 +44,12 @@
<view :class="[articleTypeAction === index ? 'article-task-line--action' : 'article-task-line--none']" /> <view :class="[articleTypeAction === index ? 'article-task-line--action' : 'article-task-line--none']" />
</view> </view>
</view> </view>
<view class="article-list">
<view class="article-item" v-for="(item, index) in articleDeepTypeList" :key="item.id" @click="onArticleDeepTypeClick(item, index)">
<view :class="[articleDeepTypeAction === index ? 'article-item-name--action' : 'article-item-name--none']">{{ item.name }}</view>
<view :class="[articleDeepTypeAction === index ? 'article-task-line--action' : 'article-task-line--none']" />
</view>
</view>
<view v-for="(item, index) in articleList" :key="item.id" @click="onArticleClick(item, index)"> <view v-for="(item, index) in articleList" :key="item.id" @click="onArticleClick(item, index)">
<view v-if="index < 3" class="article-content"> <view v-if="index < 3" class="article-content">
<view class="article-left"> <view class="article-left">
...@@ -86,79 +92,104 @@ export default { ...@@ -86,79 +92,104 @@ export default {
address: '获取位置', address: '获取位置',
bannerList: [], bannerList: [],
noticeList: [], noticeList: [],
articleTypeList: [], articleTypeList: [],
articleTypeAction: 0, articleTypeAction: 0,
articleTypeId: 0, articleTypeId: 0,
articleDeepTypeList: [],
articleDeepTypeAction: 0,
articleDeepTypeId: 0,
articleList: [], articleList: [],
}; }
}, },
onLoad(query) { onLoad(query) {
this.fetchBannerData(); this.fetchBannerData()
this.fetchNoticeData(); this.fetchNoticeData()
this.fetchArticleTypeData(); this.fetchArticleTypeData()
}, },
methods: { methods: {
async fetchBannerData() { async fetchBannerData() {
const { list } = await uni.$u.http.get('/api/app/banner/list'); const { list } = await uni.$u.http.get('/api/app/banner/list')
this.bannerList = list; this.bannerList = list
}, },
async fetchNoticeData() { async fetchNoticeData() {
const { list } = await uni.$u.http.get('/api/app/notice/list'); const { list } = await uni.$u.http.get('/api/app/notice/list')
this.noticeList = list; this.noticeList = list
}, },
async fetchArticleTypeData() { async fetchArticleTypeData() {
const { list } = await uni.$u.http.get('/api/app/articletype/list'); const { list } = await uni.$u.http.get('/api/app/articletype/list')
this.articleTypeList = list; this.articleTypeList = list
this.articleTypeId = list[0]?.id ?? 0; if (list.length <= 0) return
this.fetchArticleData(); const firstId = list[0]?.id ?? 0
this.fetchArticleDeepTypeData(firstId)
},
async fetchArticleDeepTypeData(id) {
const url = `/api/backend/articletype/list?parent_id=${id}`
const { list } = await uni.$u.http.get(url)
this.articleDeepTypeList = list
if (list.length <= 0) return
this.articleDeepTypeId = list[0]?.id
this.fetchArticleData()
}, },
async fetchArticleData() { async fetchArticleData() {
const { list } = await uni.$u.http.get('/api/article/list', { const { list } = await uni.$u.http.get('/api/article/list', {
params: { params: {
article_type_id: this.articleTypeId, article_type_id: this.articleDeepTypeId,
}, },
}); })
this.articleList = list; this.articleList = list
}, },
selectAddress() { selectAddress() {
console.log('获取位置'); console.log('获取位置')
}, },
onArticleTypeClick(item, index) { onArticleTypeClick(item, index) {
if (this.articleTypeAction === index) return; if (this.articleTypeAction === index) return
this.articleTypeAction = index; this.articleTypeAction = index
this.articleTypeId = item.id; this.articleTypeId = item.id
this.fetchArticleData(); this.articleDeepTypeAction = 0
// this.fetchArticleData()
this.fetchArticleDeepTypeData(item.id)
},
onArticleDeepTypeClick(item, index) {
if (this.articleDeepTypeAction === index) return
this.articleDeepTypeAction = index
this.articleDeepTypeId = item.id
this.fetchArticleData()
}, },
articleMore() { articleMore() {
uni.$u.route({ url: 'pages/article-list/index' }); uni.$u.route({ url: 'pages/article-list/index' })
}, },
onArticleClick(item, index) { onArticleClick(item, index) {
uni.$u.route({ url: 'pages/article-detail/index', params: { id: item.id } }); uni.$u.route({ url: 'pages/article-detail/index', params: { id: item.id } })
}, },
onGetAddress() { onGetAddress() {
uni.chooseLocation({ uni.chooseLocation({
success: (result) => { success: (result) => {
this.address = result.address; this.address = result.address
}, },
}); })
}, },
onBannerClick(item, index) { onBannerClick(item, index) {
if (!item.jump_id) return; if (!item.jump_id) return
uni.$u.route({ url: 'pages/article-detail/index', params: { id: item.jump_id } }); uni.$u.route({ url: 'pages/article-detail/index', params: { id: item.jump_id } })
}, },
}, },
}; }
</script> </script>
<style lang="scss"> <style lang="scss">
......
...@@ -38,7 +38,7 @@ export const bannerList = [ ...@@ -38,7 +38,7 @@ export const bannerList = [
desc: '', desc: '',
img: 'https://qiniu.yuhuofei.it/Fqvl7ItsPbNqxgln8y4ikCQpHvog', img: 'https://qiniu.yuhuofei.it/Fqvl7ItsPbNqxgln8y4ikCQpHvog',
}, },
]; ]
export const noticeList = [ export const noticeList = [
{ object_name: 'notice', get_points: 100, object_type: 'default', id: 293, weight: 0, content: '\u201c\u4fee\u4fee\u201d\u968f\u624b\u62cd\u5ba1\u6838\u901a\u8fc7' }, { object_name: 'notice', get_points: 100, object_type: 'default', id: 293, weight: 0, content: '\u201c\u4fee\u4fee\u201d\u968f\u624b\u62cd\u5ba1\u6838\u901a\u8fc7' },
...@@ -46,12 +46,12 @@ export const noticeList = [ ...@@ -46,12 +46,12 @@ export const noticeList = [
{ object_name: 'notice', get_points: 200, object_type: 'default', id: 291, weight: 0, content: '\u201c\u9999\u828b\u201d\u4efb\u52a1\u5ba1\u6838\u901a\u8fc7' }, { object_name: 'notice', get_points: 200, object_type: 'default', id: 291, weight: 0, content: '\u201c\u9999\u828b\u201d\u4efb\u52a1\u5ba1\u6838\u901a\u8fc7' },
{ object_name: 'notice', get_points: 200, object_type: 'default', id: 290, weight: 0, content: '\u201c\u7530\u91ce\u201d\u4efb\u52a1\u5ba1\u6838\u901a\u8fc7' }, { object_name: 'notice', get_points: 200, object_type: 'default', id: 290, weight: 0, content: '\u201c\u7530\u91ce\u201d\u4efb\u52a1\u5ba1\u6838\u901a\u8fc7' },
{ object_name: 'notice', get_points: 200, object_type: 'default', id: 289, weight: 0, content: '\u201c\u675c\u9e43\u201d\u4efb\u52a1\u5ba1\u6838\u901a\u8fc7' }, { object_name: 'notice', get_points: 200, object_type: 'default', id: 289, weight: 0, content: '\u201c\u675c\u9e43\u201d\u4efb\u52a1\u5ba1\u6838\u901a\u8fc7' },
]; ]
export const articleTypeList = [ export const articleTypeList = [
{ object_name: 'articletype', status: 1, object_type: 'default', name: '\u5927\u57ce\u5c0f\u4e8b', id: 15, weight: 1 }, { object_name: 'articletype', status: 1, object_type: 'default', name: '\u5927\u57ce\u5c0f\u4e8b', id: 15, weight: 1 },
{ object_name: 'articletype', status: 1, object_type: 'default', name: '\u653f\u7b56\u5ba3\u4f20', id: 16, weight: 0 }, { object_name: 'articletype', status: 1, object_type: 'default', name: '\u653f\u7b56\u5ba3\u4f20', id: 16, weight: 0 },
]; ]
export const articleList = [ export const articleList = [
{ {
...@@ -414,4 +414,4 @@ export const articleList = [ ...@@ -414,4 +414,4 @@ export const articleList = [
get_like_num: 0, get_like_num: 0,
follow_status: false, follow_status: false,
}, },
]; ]
...@@ -11,20 +11,20 @@ export default { ...@@ -11,20 +11,20 @@ export default {
data() { data() {
return { return {
content: '', content: '',
}; }
}, },
onLoad(query) { onLoad(query) {
this.fetchContent(); this.fetchContent()
}, },
methods: { methods: {
async fetchContent() { async fetchContent() {
const { list } = await uni.$u.http.get('/api/app/textintroduction/list', { params: { text_type: 5 } }); const { list } = await uni.$u.http.get('/api/app/textintroduction/list', { params: { text_type: 5 } })
this.content = list[0]?.content ?? ''; this.content = list[0]?.content ?? ''
}, },
}, },
}; }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -26,9 +26,9 @@ ...@@ -26,9 +26,9 @@
</template> </template>
<script> <script>
import { createList, getList } from '@/utils/list'; import { createList, getList } from '@/utils/list'
import { titleMap, record } from '@/pages/mine-integral-bonus/mock'; import { titleMap, record } from '@/pages/mine-integral-bonus/mock'
import LoadMore from '@/components/LoadMore'; import LoadMore from '@/components/LoadMore'
export default { export default {
components: { LoadMore }, components: { LoadMore },
...@@ -39,31 +39,31 @@ export default { ...@@ -39,31 +39,31 @@ export default {
show: false, show: false,
list: createList(), list: createList(),
}; }
}, },
onLoad(query) { onLoad(query) {
// this.record = record; // this.record = record;
this.fetchList(); this.fetchList()
}, },
async onPullDownRefresh() { async onPullDownRefresh() {
this.list = createList(); this.list = createList()
await this.fetchList(); await this.fetchList()
uni.stopPullDownRefresh(); uni.stopPullDownRefresh()
}, },
onReachBottom() { onReachBottom() {
this.fetchList(); this.fetchList()
}, },
methods: { methods: {
async fetchList() { async fetchList() {
await getList(this, 'list', ['/api/app/pointsrecord/list', {}]); await getList(this, 'list', ['/api/app/pointsrecord/list', {}])
console.log(this.list); console.log(this.list)
}, },
}, },
}; }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -6,7 +6,7 @@ export const titleMap = { ...@@ -6,7 +6,7 @@ export const titleMap = {
5: '随手拍', 5: '随手拍',
6: '每日签到补签', 6: '每日签到补签',
7: '提现', 7: '提现',
}; }
export const record = [ export const record = [
{ {
...@@ -295,4 +295,4 @@ export const record = [ ...@@ -295,4 +295,4 @@ export const record = [
created: '2021-05-07 10:24:46', created: '2021-05-07 10:24:46',
points_type: 1, points_type: 1,
}, },
]; ]
...@@ -34,9 +34,9 @@ ...@@ -34,9 +34,9 @@
</template> </template>
<script> <script>
import { createList, getList } from '@/utils/list'; import { createList, getList } from '@/utils/list'
import LoadMore from '@/components/LoadMore'; import LoadMore from '@/components/LoadMore'
import { myCopy } from '@/utils/util'; import { myCopy } from '@/utils/util'
export default { export default {
components: { LoadMore }, components: { LoadMore },
...@@ -45,33 +45,33 @@ export default { ...@@ -45,33 +45,33 @@ export default {
record: [], record: [],
list: createList(), list: createList(),
}; }
}, },
onLoad(query) { onLoad(query) {
this.fetchList(); this.fetchList()
}, },
async onPullDownRefresh() { async onPullDownRefresh() {
this.list = createList(); this.list = createList()
await this.fetchList(); await this.fetchList()
uni.stopPullDownRefresh(); uni.stopPullDownRefresh()
}, },
onReachBottom() { onReachBottom() {
this.fetchList(); this.fetchList()
}, },
methods: { methods: {
async fetchList() { async fetchList() {
await getList(this, 'list', ['/api/withdrawal_record/list', {}]); await getList(this, 'list', ['/api/withdrawal_record/list', {}])
}, },
onCopy(item, index) { onCopy(item, index) {
myCopy(item.order_num); myCopy(item.order_num)
}, },
}, },
}; }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -125,4 +125,4 @@ export const record = [ ...@@ -125,4 +125,4 @@ export const record = [
order_num: '<function generate_num at 0x7fded13e31e0>', order_num: '<function generate_num at 0x7fded13e31e0>',
created: '2021-08-19 14:41:56', created: '2021-08-19 14:41:56',
}, },
]; ]
...@@ -55,51 +55,51 @@ export default { ...@@ -55,51 +55,51 @@ export default {
warnShow: false, warnShow: false,
userInfo: {}, userInfo: {},
}; }
}, },
onLoad(query) { onLoad(query) {
this.fetchUserInfo(); this.fetchUserInfo()
}, },
methods: { methods: {
onSubmitClick() { onSubmitClick() {
this.submitTitle = '提现'; this.submitTitle = '提现'
this.submitContent = '目前奖金 ' + this.userInfo.integral / 100; this.submitContent = '目前奖金 ' + this.userInfo.integral / 100
this.submitShowCancel = true; this.submitShowCancel = true
this.submitShow = true; this.submitShow = true
}, },
async onSubmitConfirm() { async onSubmitConfirm() {
if (!this.submitValue) return uni.$u.toast('请输入金额'); if (!this.submitValue) return uni.$u.toast('请输入金额')
try { try {
uni.showLoading({}); uni.showLoading({})
await this.fetchSubmit(); await this.fetchSubmit()
this.onSubmitCancel(); this.onSubmitCancel()
uni.hideLoading(); uni.hideLoading()
this.successShow = true; this.successShow = true
} catch (e) { } catch (e) {
this.onSubmitCancel(); this.onSubmitCancel()
} finally { } finally {
} }
}, },
async fetchSubmit() { async fetchSubmit() {
await uni.$u.http.post('/api/withdrawal', { amount: Number(this.submitValue ?? 0) * 100 }); await uni.$u.http.post('/api/withdrawal', { amount: Number(this.submitValue ?? 0) * 100 })
}, },
async fetchUserInfo() { async fetchUserInfo() {
const { detail } = await uni.$u.http.get('/api/user_center/detail'); const { detail } = await uni.$u.http.get('/api/user_center/detail')
this.userInfo = detail; this.userInfo = detail
}, },
onSubmitCancel() { onSubmitCancel() {
this.submitValue = ''; this.submitValue = ''
this.submitShow = false; this.submitShow = false
}, },
}, },
}; }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<view class="one">{{ option.name }}</view> <view class="one">{{ option.name }}</view>
</view> </view>
<view class="photo_list"> <view class="photo_list">
<view class="photo_item" v-for="(val, index) in mediaList.filter(v => v.type === option.type)" :key="val.id" @click="previewVideo(val, index)"> <view class="photo_item" v-for="(val, index) in mediaList.filter((v) => v.type === option.type)" :key="val.id" @click="previewVideo(val, index)">
<image v-if="val.type === 'image'" mode="aspectFill" :src="val.url" style="display: block; width: 168rpx; height: 168rpx; border-radius: 16rpx" /> <image v-if="val.type === 'image'" mode="aspectFill" :src="val.url" style="display: block; width: 168rpx; height: 168rpx; border-radius: 16rpx" />
<view v-else class="play-wrapper"> <view v-else class="play-wrapper">
<video :controls="video.fullscreen" :object-fit="videoFit" :id="`myVideo${index}`" class="upload_img" :src="val.url" @fullscreenchange="onVideoFullscreenChange" /> <video :controls="video.fullscreen" :object-fit="videoFit" :id="`myVideo${index}`" class="upload_img" :src="val.url" @fullscreenchange="onVideoFullscreenChange" />
...@@ -83,67 +83,70 @@ export default { ...@@ -83,67 +83,70 @@ export default {
photoDetail: [], photoDetail: [],
video: { video: {
ctx: null, ctx: null,
fullscreen: false fullscreen: false,
},
} }
};
}, },
computed: { computed: {
videoFit() { videoFit() {
return this.video.fullscreen ? 'contain' : 'cover' return this.video.fullscreen ? 'contain' : 'cover'
} },
}, },
onLoad(query) { onLoad(query) {
this.query = query; this.query = query
this.fetchPhotoDetail(); this.fetchPhotoDetail()
}, },
methods: { methods: {
async fetchPhotoDetail() { async fetchPhotoDetail() {
const { detail } = await uni.$u.http.get('/api/app/phototask/detail', { params: { id: this.query.id } }); const { detail } = await uni.$u.http.get('/api/app/phototask/detail', { params: { id: this.query.id } })
const dataList = [detail]; const dataList = [detail]
dataList.forEach((item) => { dataList.forEach((item) => {
item.image_list = item.image_list ? item.image_list.split(',') : []; item.image_list = item.image_list ? item.image_list.split(',') : []
item.video_list = item.video_list ? item.video_list.split(',') : []; item.video_list = item.video_list ? item.video_list.split(',') : []
item.put_date = item.put_date.substring(0, 16); item.put_date = item.put_date.substring(0, 16)
item.image_list.forEach((element) => { item.image_list.forEach((element) => {
this.mediaList.push({ this.mediaList.push({
id: uni.$u.guid(), id: uni.$u.guid(),
type: 'image', type: 'image',
url: element, url: element,
}); })
}); })
item.video_list.forEach((element, index) => { item.video_list.forEach((element, index) => {
this.mediaList.push({ this.mediaList.push({
id: uni.$u.guid(), id: uni.$u.guid(),
type: 'video', type: 'video',
url: element, url: element,
}); })
}); })
}); })
this.mediaList = this.mediaList.map((value, index) => ({ this.mediaList = this.mediaList.map((value, index) => ({
...value, ...value,
videoContext: uni.createVideoContext(`myVideo${index}`), videoContext: uni.createVideoContext(`myVideo${index}`),
})); }))
this.photoDetail = dataList; this.photoDetail = dataList
}, },
// 预览视频 // 预览视频
previewVideo(item, index) { previewVideo(item, index) {
if (item.type === 'video') { if (item.type === 'video') {
// this.mediaList[index].videoContext.requestFullScreen(); // this.mediaList[index].videoContext.requestFullScreen();
const ctx = this.video.ctx = uni.createVideoContext(`myVideo${index}`) const ctx = (this.video.ctx = uni.createVideoContext(`myVideo${index}`))
ctx.play() ctx.play()
// HACK: iOS 需要延迟一下才能全屏 // HACK: iOS 需要延迟一下才能全屏
setTimeout(() => { setTimeout(
() => {
ctx.requestFullScreen() ctx.requestFullScreen()
}, uni.$u.os() === 'ios' ? 300 : 0) },
uni.$u.os() === 'ios' ? 300 : 0
)
} }
if (item.type === 'image') { if (item.type === 'image') {
uni.previewImage({ uni.previewImage({
urls: [item.url], urls: [item.url],
}); })
} }
}, },
...@@ -165,7 +168,7 @@ export default { ...@@ -165,7 +168,7 @@ export default {
{ {
name: '视频', name: '视频',
type: 'video', type: 'video',
} },
] ]
const res = [] const res = []
...@@ -176,9 +179,9 @@ export default { ...@@ -176,9 +179,9 @@ export default {
res.push(actionsOptions[1]) res.push(actionsOptions[1])
} }
return res return res
}
}, },
}; },
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -44,4 +44,4 @@ export const photoDetail = { ...@@ -44,4 +44,4 @@ export const photoDetail = {
follow_num: 0, follow_num: 0,
position: '\u5fb7\u653f\u8def\u5357\u4e00\u5df7', position: '\u5fb7\u653f\u8def\u5357\u4e00\u5df7',
remark: '\u901a\u8fc7', remark: '\u901a\u8fc7',
}; }
...@@ -110,9 +110,9 @@ ...@@ -110,9 +110,9 @@
</template> </template>
<script> <script>
import { examineItem, examineList } from '@/pages/mine-picture/mock'; import { examineItem, examineList } from '@/pages/mine-picture/mock'
import { getList, createList } from '@/utils/list'; import { getList, createList } from '@/utils/list'
import LoadMore from '@/components/LoadMore'; import LoadMore from '@/components/LoadMore'
export default { export default {
components: { LoadMore }, components: { LoadMore },
...@@ -124,36 +124,36 @@ export default { ...@@ -124,36 +124,36 @@ export default {
examineList, examineList,
list: createList(), list: createList(),
}; }
}, },
onLoad(query) { onLoad(query) {
this.fetchExamineList(); this.fetchExamineList()
}, },
methods: { methods: {
async fetchExamineList() { async fetchExamineList() {
const status = this.ExamineIdx + 1; const status = this.ExamineIdx + 1
await getList(this, 'list', ['/api/app/phototask/list', { status }], { await getList(this, 'list', ['/api/app/phototask/list', { status }], {
transform: (list) => list.map((value) => ({ ...value })), transform: (list) => list.map((value) => ({ ...value })),
abandon: () => status !== this.ExamineIdx + 1, abandon: () => status !== this.ExamineIdx + 1,
}); })
console.log(this.list); console.log(this.list)
}, },
changeExamine(item, index) { changeExamine(item, index) {
if (this.ExamineIdx === index) return; if (this.ExamineIdx === index) return
this.ExamineIdx = index; this.ExamineIdx = index
this.list = createList(); this.list = createList()
this.fetchExamineList(); this.fetchExamineList()
}, },
onItemClick(item, index) { onItemClick(item, index) {
uni.$u.route({ url: 'pages/mine-picture-detail/index', params: { id: item.id } }); uni.$u.route({ url: 'pages/mine-picture-detail/index', params: { id: item.id } })
}, },
}, },
}; }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
export const examineItem = [{ name: '审核中' }, { name: '已通过' }, { name: '未通过' }]; export const examineItem = [{ name: '审核中' }, { name: '已通过' }, { name: '未通过' }]
export const examineList = [ export const examineList = [
{ {
...@@ -92,4 +92,4 @@ export const examineList = [ ...@@ -92,4 +92,4 @@ export const examineList = [
position: '\u4e94\u8c61\u822a\u6d0b\u57ce', position: '\u4e94\u8c61\u822a\u6d0b\u57ce',
remark: null, remark: null,
}, },
]; ]
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
<view class="my_items" @click="getAuthentication"> <view class="my_items" @click="getAuthentication">
<view class="my_item_left"> <view class="my_item_left">
<image mode="aspectFill" class="task_icon" src="/static/icon/ic_wd_gy@2x.png" /> <image mode="aspectFill" class="task_icon" src="/static/icon/ic_wd_gy@2x.png" />
<view class="item_name">{{!Look ? '实名验证' : '已完成认证'}}</view> <view class="item_name">{{ !Look ? '实名验证' : '已完成认证' }}</view>
</view> </view>
<image mode="aspectFill" class="arrow_right" src="/static/icon/arrow_right1@2x.png" /> <image mode="aspectFill" class="arrow_right" src="/static/icon/arrow_right1@2x.png" />
</view> </view>
...@@ -57,8 +57,6 @@ ...@@ -57,8 +57,6 @@
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<view class="unauthorized" v-else> <view class="unauthorized" v-else>
...@@ -81,56 +79,53 @@ export default { ...@@ -81,56 +79,53 @@ export default {
token: null, token: null,
canIUseGetUserProfile: false, canIUseGetUserProfile: false,
userDetail: {}, userDetail: {},
Look:true, Look: true,
}; }
}, },
onLoad(query) {}, onLoad(query) {},
onShow() { onShow() {
this.token = '1234qwer1234'; this.token = '1234qwer1234'
this.fetchUserInfo(); this.fetchUserInfo()
}, },
methods: { methods: {
async fetchUserInfo() { async fetchUserInfo() {
const { detail } = await uni.$u.http.get('/api/user_center/detail'); const { detail } = await uni.$u.http.get('/api/user_center/detail')
console.log(detail); console.log(detail)
this.userDetail = detail; this.userDetail = detail
this.Look = detail.is_real_auth this.Look = detail.is_real_auth
}, },
myPhoto() { myPhoto() {
uni.$u.route({ url: 'pages/mine-picture/index' }); uni.$u.route({ url: 'pages/mine-picture/index' })
}, },
about() { about() {
uni.$u.route({ url: 'pages/mine-about/index' }); uni.$u.route({ url: 'pages/mine-about/index' })
}, },
getAuthentication(){ getAuthentication() {
if(!this.Look){ if (!this.Look) {
// this.modalShow=true // this.modalShow=true
uni.$u.route({ url: 'pages/Authentication/Authentication' }); uni.$u.route({ url: 'pages/Authentication/Authentication' })
}else{ } else {
uni.$u.toast('已经完成实名认证'); uni.$u.toast('已经完成实名认证')
} }
// console.log(123); // console.log(123);
}, },
async tailor() { async tailor() {
try { try {
await uni.$u.http.get('/api/user/logout', { params: { token: '' } }); await uni.$u.http.get('/api/user/logout', { params: { token: '' } })
uni.$u.toast('注销登录成功'); uni.$u.toast('注销登录成功')
} finally { } finally {
} }
}, },
myIntegral() { myIntegral() {
uni.$u.route({ url: 'pages/mine-integral/index' }); uni.$u.route({ url: 'pages/mine-integral/index' })
}, },
}, },
}; }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -9,4 +9,4 @@ export const userDetail = { ...@@ -9,4 +9,4 @@ export const userDetail = {
created: '2021-05-07 10:24:27', created: '2021-05-07 10:24:27',
is_receive: true, is_receive: true,
tag_name: '', tag_name: '',
}; }
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
</template> </template>
<script> <script>
import { actionsOptions } from '@/pages/record-content/mock'; import { actionsOptions } from '@/pages/record-content/mock'
export default { export default {
name: 'CertificateTypeActionSheet', name: 'CertificateTypeActionSheet',
...@@ -19,18 +19,18 @@ export default { ...@@ -19,18 +19,18 @@ export default {
return { return {
show: false, show: false,
actionsOptions, actionsOptions,
}; }
}, },
methods: { methods: {
async onActionSheetClose() { async onActionSheetClose() {
this.show = false; this.show = false
}, },
async onActionSheetSelect(item) { async onActionSheetSelect(item) {
this.success(item); this.success(item)
}, },
}, },
}; }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -18,18 +18,18 @@ export default { ...@@ -18,18 +18,18 @@ export default {
return { return {
show: false, show: false,
// actionsOptions, // actionsOptions,
}; }
}, },
methods: { methods: {
async onActionSheetClose() { async onActionSheetClose() {
this.show = false; this.show = false
}, },
async onActionSheetSelect(item) { async onActionSheetSelect(item) {
this.success(item); this.success(item)
}, },
}, },
}; }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<view class="detail_container"> <view class="detail_container">
<view v-if="IllegalShow" class="content"> <view v-if="IllegalShow" class="content">
<!-- 违法时间--> <!-- 违法时间-->
<view class="step_box" style="margin-top: 0;"> <view class="step_box" style="margin-top: 0">
<view class="tep_one"> <view class="tep_one">
<image mode="aspectFill" class="tep_icon" src="/static/icon/ic_rw_neirong@2x.png" /> <image mode="aspectFill" class="tep_icon" src="/static/icon/ic_rw_neirong@2x.png" />
<view class="one">{{ '违法时间' }}</view> <view class="one">{{ '违法时间' }}</view>
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
</view> </view>
--> -->
<view class="report_box" style="margin-top: 50rpx;"> <view class="report_box" style="margin-top: 50rpx">
<view class="report_one" @click="selectNumberPlatesShow = true"> <view class="report_one" @click="selectNumberPlatesShow = true">
<view class="report_left"> <view class="report_left">
<image mode="aspectFill" class="tep_icon" src="/static/icon/ic_rw_zhixing@2x.png" /> <image mode="aspectFill" class="tep_icon" src="/static/icon/ic_rw_zhixing@2x.png" />
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
</view> </view>
<!-- 上报类型--> <!-- 上报类型-->
<view class="report_box" style="margin-top: 52rpx;"> <view class="report_box" style="margin-top: 52rpx">
<view class="report_one" @click="/* 暂时不给选择其它类型 choice */"> <view class="report_one" @click="/* 暂时不给选择其它类型 choice */">
<view class="report_left"> <view class="report_left">
<image mode="aspectFill" class="tep_icon" src="/static/icon/ic_rw_zhixing@2x.png" /> <image mode="aspectFill" class="tep_icon" src="/static/icon/ic_rw_zhixing@2x.png" />
...@@ -137,14 +137,21 @@ ...@@ -137,14 +137,21 @@
</view> </view>
<view class="photo_wrapper"> <view class="photo_wrapper">
<view class="photo_list"> <view class="photo_list">
<view class="photo_item" bindtap="preview" v-for="(item, index) in photoList.filter(v => v.type === option.type)" :key="item.id"> <view class="photo_item" bindtap="preview" v-for="(item, index) in photoList.filter((v) => v.type === option.type)" :key="item.id">
<view v-if="item.status === 'loading'" class="photo_item--loading"> </view> <view v-if="item.status === 'loading'" class="photo_item--loading"> </view>
<view v-else @click="previewVideo(item, index)"> <view v-else @click="previewVideo(item, index)">
<!-- <image mode="aspectFill" class="upload_img" src="{{item}}" /> --> <!-- <image mode="aspectFill" class="upload_img" src="{{item}}" /> -->
<image mode="aspectFill" v-if="item.type === 'image'" :src="getThumbnail(item.url)" style="display: block; width: 168rpx; height: 168rpx; border-radius: 16rpx" /> <image mode="aspectFill" v-if="item.type === 'image'" :src="getThumbnail(item.url)" style="display: block; width: 168rpx; height: 168rpx; border-radius: 16rpx" />
<view v-else class="play-wrapper"> <view v-else class="play-wrapper">
<video :controls="video.fullscreen" :object-fit="videoFit" :id="`myVideo${index}`" class="upload_img" :src="item.url" @fullscreenchange="onVideoFullscreenChange" /> <video
:controls="video.fullscreen"
:object-fit="videoFit"
:id="`myVideo${index}`"
class="upload_img"
:src="item.url"
@fullscreenchange="onVideoFullscreenChange"
/>
<image src="/static/icon/ic_sj_bf@2x.png" mode="aspectFill" class="play-icon" /> <image src="/static/icon/ic_sj_bf@2x.png" mode="aspectFill" class="play-icon" />
</view> </view>
<!-- <video class="upload_img" v-else :src="item.url" :show-fullscreen-btn="false" :show-play-btn="false" :show-center-play-btn="false" />--> <!-- <video class="upload_img" v-else :src="item.url" :show-fullscreen-btn="false" :show-play-btn="false" :show-center-play-btn="false" />-->
...@@ -282,14 +289,21 @@ ...@@ -282,14 +289,21 @@
</view> </view>
<view class="photo_wrapper"> <view class="photo_wrapper">
<view class="photo_list"> <view class="photo_list">
<view class="photo_item" bindtap="preview" v-for="(item, index) in photoList.filter(v => v.type === option.type)" :key="item.id"> <view class="photo_item" bindtap="preview" v-for="(item, index) in photoList.filter((v) => v.type === option.type)" :key="item.id">
<view v-if="item.status === 'loading'" class="photo_item--loading"></view> <view v-if="item.status === 'loading'" class="photo_item--loading"></view>
<view v-else @click="previewVideo(item, index)"> <view v-else @click="previewVideo(item, index)">
<!-- <image mode="aspectFill" class="upload_img" src="{{item}}" /> --> <!-- <image mode="aspectFill" class="upload_img" src="{{item}}" /> -->
<image mode="aspectFill" v-if="item.type === 'image'" :src="getThumbnail(item.url)" style="display: block; width: 168rpx; height: 168rpx; border-radius: 16rpx" /> <image mode="aspectFill" v-if="item.type === 'image'" :src="getThumbnail(item.url)" style="display: block; width: 168rpx; height: 168rpx; border-radius: 16rpx" />
<view v-else class="play-wrapper"> <view v-else class="play-wrapper">
<video :controls="video.fullscreen" :object-fit="videoFit" :id="`myVideo${index}`" class="upload_img" :src="item.url" @fullscreenchange="onVideoFullscreenChange" /> <video
:controls="video.fullscreen"
:object-fit="videoFit"
:id="`myVideo${index}`"
class="upload_img"
:src="item.url"
@fullscreenchange="onVideoFullscreenChange"
/>
<image src="/static/icon/ic_sj_bf@2x.png" mode="aspectFill" class="play-icon" /> <image src="/static/icon/ic_sj_bf@2x.png" mode="aspectFill" class="play-icon" />
</view> </view>
<!-- <video class="upload_img" v-else :src="item.url" :show-fullscreen-btn="false" :show-play-btn="false" :show-center-play-btn="false" />--> <!-- <video class="upload_img" v-else :src="item.url" :show-fullscreen-btn="false" :show-play-btn="false" :show-center-play-btn="false" />-->
...@@ -354,7 +368,7 @@ ...@@ -354,7 +368,7 @@
readonly readonly
disabled disabled
class="title_input" class="title_input"
@click="isIncivility ? '' : showIllegalTime = true" @click="isIncivility ? '' : (showIllegalTime = true)"
/> />
<!-- <view class="clear">--> <!-- <view class="clear">-->
<!-- <text style="float: right; font-size: 28rpx; font-weight: 400; color: #656565; margin-right: 5px">{{ IllegalForm.illegal_time.length }}/{{ maxWord }}</text>--> <!-- <text style="float: right; font-size: 28rpx; font-weight: 400; color: #656565; margin-right: 5px">{{ IllegalForm.illegal_time.length }}/{{ maxWord }}</text>-->
...@@ -468,10 +482,10 @@ ...@@ -468,10 +482,10 @@
</template> </template>
<script> <script>
import { actionsOptions, week } from '@/pages/record-content/mock'; import { actionsOptions, week } from '@/pages/record-content/mock'
import UploadActionSheet from '@/pages/record-content/UploadActionSheet'; import UploadActionSheet from '@/pages/record-content/UploadActionSheet'
import CertificateTypeActionSheet from '@/pages/record-content/CertificateTypeActionSheet'; import CertificateTypeActionSheet from '@/pages/record-content/CertificateTypeActionSheet'
import { baseEncode, getImageInfo } from '@/utils/util'; import { baseEncode, getImageInfo } from '@/utils/util'
const maxUploadVideoSizeM = 50 // M const maxUploadVideoSizeM = 50 // M
const maxUploadVideoSize = maxUploadVideoSizeM * 1000 * 1000 // 单位 B,参考 macOS 用 1000 计算 const maxUploadVideoSize = maxUploadVideoSizeM * 1000 * 1000 // 单位 B,参考 macOS 用 1000 计算
...@@ -481,7 +495,7 @@ const typeMap = { ...@@ -481,7 +495,7 @@ const typeMap = {
illegality: '交通违法举报', illegality: '交通违法举报',
incivility: '城市管理违法举报', // '城市不文明行为举报', incivility: '城市管理违法举报', // '城市不文明行为举报',
fault: '交通设施故障上报', fault: '交通设施故障上报',
dispersion: '渣土运输车辆未覆盖或沿途泄露、抛撒' dispersion: '渣土运输车辆未覆盖或沿途泄露、抛撒',
} }
const numberPlateMap = new Map([ const numberPlateMap = new Map([
...@@ -491,13 +505,13 @@ const numberPlateMap = new Map([ ...@@ -491,13 +505,13 @@ const numberPlateMap = new Map([
['4', '小型新能源汽车(渐变绿底黑字)'], ['4', '小型新能源汽车(渐变绿底黑字)'],
['5', '轻便摩托车(蓝底白字)'], ['5', '轻便摩托车(蓝底白字)'],
['6', '普通摩托车(黄底黑字)'], ['6', '普通摩托车(黄底黑字)'],
['7', "电动自行车(绿牌白字)"], ['7', '电动自行车(绿牌白字)'],
]) ])
const uploadSourceTypeMap = { const uploadSourceTypeMap = {
1: ['camera', 'album'], 1: ['camera', 'album'],
2: ['camera'], 2: ['camera'],
3: ['album'] 3: ['album'],
} }
export default { export default {
...@@ -553,7 +567,7 @@ export default { ...@@ -553,7 +567,7 @@ export default {
numberPlateMap, numberPlateMap,
numberPlates: [...numberPlateMap.entries()].map(([value, name]) => ({ numberPlates: [...numberPlateMap.entries()].map(([value, name]) => ({
name, name,
value value,
})), })),
mustUploadImageCount, mustUploadImageCount,
...@@ -572,19 +586,19 @@ export default { ...@@ -572,19 +586,19 @@ export default {
realNameTitle: '申报人信息', realNameTitle: '申报人信息',
time: '申报时间', time: '申报时间',
address: '拍摄地点', address: '拍摄地点',
} },
}, },
video: { video: {
ctx: null, ctx: null,
fullscreen: false fullscreen: false,
},
} }
};
}, },
computed: { computed: {
activeItem() { activeItem() {
return this.typeList.find(v => v.id === this.id) return this.typeList.find((v) => v.id === this.id)
}, },
activeParent() { activeParent() {
return this.activeItem?.parent return this.activeItem?.parent
...@@ -617,7 +631,7 @@ export default { ...@@ -617,7 +631,7 @@ export default {
{ {
name: '视频', name: '视频',
type: 'video', type: 'video',
} },
] ]
const res = [] const res = []
...@@ -643,59 +657,54 @@ export default { ...@@ -643,59 +657,54 @@ export default {
return this.isOnlyAllowUploadImages || this.isAllowUploadImagesAndVideos return this.isOnlyAllowUploadImages || this.isAllowUploadImagesAndVideos
}, },
uploadTitle() { uploadTitle() {
return `上传${this.uploadActionsOptions.map(v => v.name).join('/')}` return `上传${this.uploadActionsOptions.map((v) => v.name).join('/')}`
}, },
videoFit() { videoFit() {
return this.video.fullscreen ? 'contain' : 'cover' return this.video.fullscreen ? 'contain' : 'cover'
}, },
numberPlateText() { numberPlateText() {
const name = this.numberPlateMap.get(this.IllegalForm.number_plate) const name = this.numberPlateMap.get(this.IllegalForm.number_plate)
console.log(name); console.log(name)
return name && name.slice(0, name.indexOf('(')) || '请选择' return (name && name.slice(0, name.indexOf('('))) || '请选择'
} },
}, },
watch: { watch: {
activeItem(v) { activeItem(v) {
this.mustUploadImageCount = mustUploadImageCount = v?.image_num this.mustUploadImageCount = mustUploadImageCount = v?.image_num
} },
}, },
onLoad(query) { onLoad(query) {
console.log(query); console.log(query)
this.query = query; this.query = query
this.fetchPhotoTaskTypeData(); this.fetchPhotoTaskTypeData()
this.fetchUserInfo() this.fetchUserInfo()
}, },
methods: { methods: {
async fetchPhotoTaskTypeData() { async fetchPhotoTaskTypeData() {
const { list } = await uni.$u.http.get('/api/app/phototasktype/list', { params: { parent_id: this.query.parent_id } }); const { list } = await uni.$u.http.get('/api/app/phototasktype/list', { params: { parent_id: this.query.parent_id } })
this.typeList = list; this.typeList = list
this.IllegalShow = list.every(({ parent }) => parent.name === '交通违法举报'); this.IllegalShow = list.every(({ parent }) => parent.name === '交通违法举报')
this.id = +this.query.detail_id; this.id = +this.query.detail_id
}, },
async fetchUserInfo() { async fetchUserInfo() {
const { const {
detail: { detail: { name, phone, certificates: certificateType, ID_number: certificateText },
name,
phone,
certificates: certificateType,
ID_number: certificateText
}
} = await uni.$u.http.get('/api/user_center/detail') } = await uni.$u.http.get('/api/user_center/detail')
this.realForm = { this.realForm = {
name, name,
phone, phone,
certificateType, certificateType,
certificateText certificateText,
} }
}, },
async choice() { async choice() {
this.show = !this.show; this.show = !this.show
}, },
/** /**
...@@ -703,7 +712,7 @@ export default { ...@@ -703,7 +712,7 @@ export default {
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async onActionSheetClose() { async onActionSheetClose() {
this.show = false; this.show = false
}, },
/** /**
...@@ -711,12 +720,12 @@ export default { ...@@ -711,12 +720,12 @@ export default {
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async onActionSheetSelect(item) { async onActionSheetSelect(item) {
console.log('onActionSheetSelect', item); console.log('onActionSheetSelect', item)
this.id = item.id; this.id = item.id
}, },
onSelectNumberPlate({ value }) { onSelectNumberPlate({ value }) {
console.log(value); console.log(value)
this.IllegalForm.number_plate = value this.IllegalForm.number_plate = value
}, },
...@@ -739,12 +748,12 @@ export default { ...@@ -739,12 +748,12 @@ export default {
uni.chooseLocation({ uni.chooseLocation({
success: (result) => { success: (result) => {
console.log(result); console.log(result)
this.longitude = result.longitude; this.longitude = result.longitude
this.latitude = result.latitude; this.latitude = result.latitude
this.address = result.address; this.address = result.address
}, },
}); })
}, },
/** /**
...@@ -757,8 +766,8 @@ export default { ...@@ -757,8 +766,8 @@ export default {
title: '提示', title: '提示',
content: `请获取地点后上传${option.name}`, content: `请获取地点后上传${option.name}`,
showCancel: false, showCancel: false,
}); })
return; return
} }
this.onUpload(option) this.onUpload(option)
/* 上传类型分开后直接打开 /* 上传类型分开后直接打开
...@@ -783,23 +792,23 @@ export default { ...@@ -783,23 +792,23 @@ export default {
type, type,
url: '', url: '',
status: 'loading', status: 'loading',
}; }
this.photoList.push(media); this.photoList.push(media)
const [_temp0, { data }] = await uni.request({ url: '/api/qiniu/token' }); const [_temp0, { data }] = await uni.request({ url: '/api/qiniu/token' })
const [_temp1, { data: res }] = await uni.uploadFile({ const [_temp1, { data: res }] = await uni.uploadFile({
url: data.upload_url, url: data.upload_url,
formData: { formData: {
token: data.upload_token, token: data.upload_token,
file, file,
}, },
}); })
const { isIncivility, activeMap } = this const { isIncivility, activeMap } = this
const myAddress = `${isIncivility ? activeMap.address : '拍摄地点'}: ${this.address}`; const myAddress = `${isIncivility ? activeMap.address : '拍摄地点'}: ${this.address}`
const myDay = `${isIncivility ? activeMap.time : '拍摄时间'}: ${uni.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM:ss')}`; const myDay = `${isIncivility ? activeMap.time : '拍摄时间'}: ${uni.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM:ss')}`
const { key } = JSON.parse(res); const { key } = JSON.parse(res)
// 水印文字大小,单位: 缇,等于1/20磅,默认值是240缇,参考DPI为72。 // 水印文字大小,单位: 缇,等于1/20磅,默认值是240缇,参考DPI为72。
// 240 缇约等于 12px // 240 缇约等于 12px
...@@ -817,19 +826,19 @@ export default { ...@@ -817,19 +826,19 @@ export default {
scale = ref / phoneWidth scale = ref / phoneWidth
imageWidth = width imageWidth = width
} }
const getRealSize = value => ~~(value * scale) // 数值只支持整数 const getRealSize = (value) => ~~(value * scale) // 数值只支持整数
// 参考文本 // 参考文本
const refText = myAddress const refText = myAddress
const dx = getRealSize(15) const dx = getRealSize(15)
const availableContentWidth = imageWidth - (dx * 2) const availableContentWidth = imageWidth - dx * 2
const smallSizeChars = refText.match(/\w|\s/g) const smallSizeChars = refText.match(/\w|\s/g)
const realCharCount = refText.length - (smallSizeChars.length / 2) const realCharCount = refText.length - smallSizeChars.length / 2
const availableFontSize = ~~(availableContentWidth / realCharCount * tPerPx) const availableFontSize = ~~((availableContentWidth / realCharCount) * tPerPx)
const normalFontSize = getRealSize(16 * tPerPx) const normalFontSize = getRealSize(16 * tPerPx)
const fontSize = Math.min(availableFontSize, normalFontSize) const fontSize = Math.min(availableFontSize, normalFontSize)
const timeDy = getRealSize(10) const timeDy = getRealSize(10)
const addressLineHeight = 1.3 const addressLineHeight = 1.3
const addressDy = ~~((timeDy + (fontSize / tPerPx)) * addressLineHeight) const addressDy = ~~((timeDy + fontSize / tPerPx) * addressLineHeight)
media.url = media.url =
type === 'image' type === 'image'
...@@ -838,16 +847,16 @@ export default { ...@@ -838,16 +847,16 @@ export default {
.replace(/\//g, '_')}/font/5b6u6L2v6ZuF6buR/fontsize/${fontSize}/fill/I0ZGRkZGRg==/dissolve/100/gravity/SouthWest/dx/${dx}/dy/${addressDy}/text/${baseEncode(myDay) .replace(/\//g, '_')}/font/5b6u6L2v6ZuF6buR/fontsize/${fontSize}/fill/I0ZGRkZGRg==/dissolve/100/gravity/SouthWest/dx/${dx}/dy/${addressDy}/text/${baseEncode(myDay)
.replace(/\+/g, '-') .replace(/\+/g, '-')
.replace(/\//g, '_')}/font/5b6u6L2v6ZuF6buR/fontsize/${fontSize}/fill/I0ZGRkZGRg==/dissolve/100/gravity/SouthWest/dx/${dx}/dy/${timeDy}` .replace(/\//g, '_')}/font/5b6u6L2v6ZuF6buR/fontsize/${fontSize}/fill/I0ZGRkZGRg==/dissolve/100/gravity/SouthWest/dx/${dx}/dy/${timeDy}`
: `${data.qn_domain}${key}`; : `${data.qn_domain}${key}`
media.status = 'finish'; media.status = 'finish'
if (type === 'video') { if (type === 'video') {
this.photoList = this.photoList.map((value, index) => ({ this.photoList = this.photoList.map((value, index) => ({
...value, ...value,
// videoContext: uni.createVideoContext(`myVideo${index}`), // videoContext: uni.createVideoContext(`myVideo${index}`),
})); }))
}
} }
};
const { activeItem } = this const { activeItem } = this
...@@ -860,14 +869,14 @@ export default { ...@@ -860,14 +869,14 @@ export default {
sourceType: uploadSourceTypeMap[activeItem.upload_mode], sourceType: uploadSourceTypeMap[activeItem.upload_mode],
success: (result) => { success: (result) => {
result.tempFiles.forEach((value, index) => { result.tempFiles.forEach((value, index) => {
upLoad(value, undefined, result.tempFilePaths[index]); upLoad(value, undefined, result.tempFilePaths[index])
}); })
}, },
fail: (result) => { fail: (result) => {
console.log(result); console.log(result)
}, },
}); })
break; break
case 'video': case 'video':
uni.chooseVideo({ uni.chooseVideo({
success: (result) => { success: (result) => {
...@@ -876,22 +885,22 @@ export default { ...@@ -876,22 +885,22 @@ export default {
uni.$u.toast(`上传的视频大小不能超过 ${maxUploadVideoSizeM}M`) uni.$u.toast(`上传的视频大小不能超过 ${maxUploadVideoSizeM}M`)
return return
} }
upLoad(result.tempFile, 'video'); upLoad(result.tempFile, 'video')
}, },
fail: (result) => { fail: (result) => {
console.log(result); console.log(result)
}, },
}); })
break; break
} }
}, },
async openSelectCertificateType() { async openSelectCertificateType() {
this.$refs.certificateTypeActionSheet.show = true; this.$refs.certificateTypeActionSheet.show = true
}, },
async onCertificateTypeChange(item) { async onCertificateTypeChange(item) {
this.realForm.certificateType = item.id; this.realForm.certificateType = item.id
}, },
/** /**
...@@ -899,39 +908,39 @@ export default { ...@@ -899,39 +908,39 @@ export default {
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async submitReview() { async submitReview() {
const t = (text = '') => uni.$u.toast(text); const t = (text = '') => uni.$u.toast(text)
const { activeMap, isIncivility, isFault, isDispersion } = this const { activeMap, isIncivility, isFault, isDispersion } = this
if (this.IllegalShow) { if (this.IllegalShow) {
if (!this.IllegalForm.illegal_time) return t('请输入违法时间'); if (!this.IllegalForm.illegal_time) return t('请输入违法时间')
if (!this.longitude) return t('请选择位置'); if (!this.longitude) return t('请选择位置')
if (!this.IllegalForm.number_plate) return t('请输入号牌种类'); if (!this.IllegalForm.number_plate) return t('请输入号牌种类')
if (!this.IllegalForm.license_plate) return t('请输入号牌号码'); if (!this.IllegalForm.license_plate) return t('请输入号牌号码')
// if (!this.IllegalForm.jurisdiction) return t('请输入所属辖区'); // if (!this.IllegalForm.jurisdiction) return t('请输入所属辖区');
// if (!this.IllegalForm.IllegalType) return t('请输入违法类型'); // if (!this.IllegalForm.IllegalType) return t('请输入违法类型');
if (!this.IllegalForm.content) return t('请输入违法行为描述'); if (!this.IllegalForm.content) return t('请输入违法行为描述')
if (!this.photoList.length) return t(`${this.uploadTitle}`); if (!this.photoList.length) return t(`${this.uploadTitle}`)
if (!this.realForm.name) return t('请输入真实姓名'); if (!this.realForm.name) return t('请输入真实姓名')
if (!this.realForm.phone) return t('请输入电话号码'); if (!this.realForm.phone) return t('请输入电话号码')
if (!this.realForm.certificateType) return t('请选择证件类型'); if (!this.realForm.certificateType) return t('请选择证件类型')
if (!this.realForm.certificateText) return t('请输入证件号码'); if (!this.realForm.certificateText) return t('请输入证件号码')
} else { } else {
if (!this.id) return t('请选择上报类型'); if (!this.id) return t('请选择上报类型')
if (!this.longitude) return t('请选择位置'); if (!this.longitude) return t('请选择位置')
if (!this.photoList.length) return t(`${this.uploadTitle}`); if (!this.photoList.length) return t(`${this.uploadTitle}`)
if (!this.IllegalForm.illegal_time) return t(`请输入${activeMap.time}`); if (!this.IllegalForm.illegal_time) return t(`请输入${activeMap.time}`)
if (isIncivility) { if (isIncivility) {
// if (!this.IllegalForm.IllegalType) return t('请输入违法类型'); // if (!this.IllegalForm.IllegalType) return t('请输入违法类型');
} }
if (isDispersion) { if (isDispersion) {
if (!this.IllegalForm.license_plate) return t('请输入涉事车辆号牌'); if (!this.IllegalForm.license_plate) return t('请输入涉事车辆号牌')
} }
// if (!this.title && !this.isIncivility) return t('请输入标题'); // if (!this.title && !this.isIncivility) return t('请输入标题');
if (!this.content) return t('请输入' + activeMap.content); if (!this.content) return t('请输入' + activeMap.content)
if (this.checked) { if (this.checked) {
if (!this.realForm.name) return t('请输入真实姓名'); if (!this.realForm.name) return t('请输入真实姓名')
if (!this.realForm.phone) return t('请输入电话号码'); if (!this.realForm.phone) return t('请输入电话号码')
if (!this.realForm.certificateType) return t('请选择证件类型'); if (!this.realForm.certificateType) return t('请选择证件类型')
if (!this.realForm.certificateText) return t('请输入证件号码'); if (!this.realForm.certificateText) return t('请输入证件号码')
} }
} }
...@@ -945,9 +954,7 @@ export default { ...@@ -945,9 +954,7 @@ export default {
await uni.$u.http.post('/api/photo_task/create', { await uni.$u.http.post('/api/photo_task/create', {
title: this.title, title: this.title,
type_id: this.id, type_id: this.id,
image_list: images image_list: images.map(({ url }) => url).join(),
.map(({ url }) => url)
.join(),
video_list: this.photoList video_list: this.photoList
.filter(({ type }) => type === 'video') .filter(({ type }) => type === 'video')
.map(({ url }) => url) .map(({ url }) => url)
...@@ -964,11 +971,11 @@ export default { ...@@ -964,11 +971,11 @@ export default {
...this.IllegalForm, ...this.IllegalForm,
content: this.IllegalShow ? this.IllegalForm.content : this.content, content: this.IllegalShow ? this.IllegalForm.content : this.content,
illegal_time: uni.$u.timeFormat(this.IllegalForm.illegal_time, 'yyyy-mm-dd hh:MM'), illegal_time: uni.$u.timeFormat(this.IllegalForm.illegal_time, 'yyyy-mm-dd hh:MM'),
}); })
uni.$u.toast('上报成功'); uni.$u.toast('上报成功')
uni.$u.route({ url: 'pages/record-finish/index', type: 'redirectTo' }); uni.$u.route({ url: 'pages/record-finish/index', type: 'redirectTo' })
} finally { } finally {
} }
}, },
...@@ -976,32 +983,35 @@ export default { ...@@ -976,32 +983,35 @@ export default {
// 预览视频 // 预览视频
previewVideo(item, index) { previewVideo(item, index) {
if (item.type === 'video') { if (item.type === 'video') {
const ctx = this.video.ctx = uni.createVideoContext(`myVideo${index}`) const ctx = (this.video.ctx = uni.createVideoContext(`myVideo${index}`))
ctx.play() ctx.play()
// HACK: iOS 需要延迟一下才能全屏 // HACK: iOS 需要延迟一下才能全屏
setTimeout(() => { setTimeout(
() => {
ctx.requestFullScreen() ctx.requestFullScreen()
}, uni.$u.os() === 'ios' ? 300 : 0) },
uni.$u.os() === 'ios' ? 300 : 0
)
} }
if (item.type === 'image') { if (item.type === 'image') {
uni.previewImage({ uni.previewImage({
urls: [item.url], urls: [item.url],
}); })
} }
}, },
cancel(item, index) { cancel(item, index) {
this.photoList.splice(this.photoList.indexOf(item), 1); this.photoList.splice(this.photoList.indexOf(item), 1)
}, },
onIllegalTimeConfirm(value) { onIllegalTimeConfirm(value) {
this.IllegalForm.illegal_time = value; this.IllegalForm.illegal_time = value
this.showIllegalTime = false; this.showIllegalTime = false
}, },
getCertificateType(value) { getCertificateType(value) {
if (!value) return ''; if (!value) return ''
return this.actionsOptions.find(({ id }) => id === value).name; return this.actionsOptions.find(({ id }) => id === value).name
}, },
getUploadTitle({ name, type }) { getUploadTitle({ name, type }) {
...@@ -1025,9 +1035,9 @@ export default { ...@@ -1025,9 +1035,9 @@ export default {
if (!fullScreen) { if (!fullScreen) {
this.video.ctx.pause() this.video.ctx.pause()
} }
}
}, },
}; },
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
export const week = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']; export const week = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
export const typeList = [ export const typeList = [
{ {
...@@ -67,7 +67,7 @@ export const typeList = [ ...@@ -67,7 +67,7 @@ export const typeList = [
weight: 6, weight: 6,
img: 'https://qiniu.yuhuofei.it/FgxfvMffyGyFb3vzHGp5ieSEwBYl', img: 'https://qiniu.yuhuofei.it/FgxfvMffyGyFb3vzHGp5ieSEwBYl',
}, },
]; ]
export const actionsOptions = [ export const actionsOptions = [
{ {
...@@ -82,4 +82,4 @@ export const actionsOptions = [ ...@@ -82,4 +82,4 @@ export const actionsOptions = [
id: 3, id: 3,
name: '社保卡', name: '社保卡',
}, },
]; ]
...@@ -17,18 +17,18 @@ export default { ...@@ -17,18 +17,18 @@ export default {
return { return {
backType: 0, backType: 0,
path: '可在“我的随手拍-审核中”查看', path: '可在“我的随手拍-审核中”查看',
}; }
}, },
methods: { methods: {
async backIndex() { async backIndex() {
if (this.backType === 0) { if (this.backType === 0) {
uni.reLaunch({ uni.reLaunch({
url: '/', url: '/',
}); })
} }
}, },
}, },
}; }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -56,37 +56,37 @@ export default { ...@@ -56,37 +56,37 @@ export default {
isFirstRecordType: 0, isFirstRecordType: 0,
isFirstRecordTypeId: 0, isFirstRecordTypeId: 0,
totalList: [] totalList: [],
}; }
}, },
computed: { computed: {
modalHeight() { modalHeight() {
return Math.ceil(window.innerHeight * 2 * 0.6); return Math.ceil(window.innerHeight * 2 * 0.6)
}, },
}, },
onLoad(query) { onLoad(query) {
this.query = query; this.query = query
console.log(query); console.log(query)
this.fetchPhotoTaskTypeData(); this.fetchPhotoTaskTypeData()
this.fetchPhotoTaskTypeDetail(); this.fetchPhotoTaskTypeDetail()
this.isFirstRecordType = this.getIsFirstRecordType(); this.isFirstRecordType = this.getIsFirstRecordType()
}, },
onShow(options) {}, onShow(options) {},
methods: { methods: {
async fetchPhotoTaskTypeData() { async fetchPhotoTaskTypeData() {
const { list } = await uni.$u.http.get('/api/app/phototasktype/list', { params: { parent_id: this.query.id } }); const { list } = await uni.$u.http.get('/api/app/phototasktype/list', { params: { parent_id: this.query.id } })
this.list = list; this.list = list
console.log(list); console.log(list)
// 可分类 // 可分类
if (list.some(v => v.category > 0)) { if (list.some((v) => v.category > 0)) {
this.totalList = Object.keys(categoryMap).map((c, index) => { this.totalList = Object.keys(categoryMap).map((c, index) => {
const category = +c const category = +c
const data = list.filter(v => v.category === category) const data = list.filter((v) => v.category === category)
const res = { const res = {
title: categoryMap[category], title: categoryMap[category],
data, data,
...@@ -99,59 +99,58 @@ export default { ...@@ -99,59 +99,58 @@ export default {
}, },
async fetchPhotoTaskTypeDetail() { async fetchPhotoTaskTypeDetail() {
const { detail } = await uni.$u.http.get('/api/app/phototasktype/detail', { params: { id: this.query.id } }); const { detail } = await uni.$u.http.get('/api/app/phototasktype/detail', { params: { id: this.query.id } })
this.title = detail.name; this.title = detail.name
this.content = detail.desc; this.content = detail.desc
}, },
async onReportClick() { async onReportClick() {
console.log('onReportClick'); console.log('onReportClick')
this.showReport = true; this.showReport = true
}, },
async onReportConfirm() { async onReportConfirm() {
if (!this.isFirstRecordType) { if (!this.isFirstRecordType) {
this.showReport = false; this.showReport = false
this.isFirstRecordType = this.getIsFirstRecordType(); this.isFirstRecordType = this.getIsFirstRecordType()
uni.$u.route({ uni.$u.route({
url: 'pages/record-content/index', url: 'pages/record-content/index',
params: { params: {
parent_id: this.query.id, parent_id: this.query.id,
detail_id: this.isFirstRecordTypeId, detail_id: this.isFirstRecordTypeId,
}, },
}); })
} }
this.showReport = false; this.showReport = false
}, },
onListClick(item, index) { onListClick(item, index) {
if (!this.isFirstRecordType) { if (!this.isFirstRecordType) {
console.log(123,'Tt'); console.log(123, 'Tt')
this.isFirstRecordTypeId = item.id; this.isFirstRecordTypeId = item.id
this.showReport = true; this.showReport = true
return; return
} }
console.log('ccc'); console.log('ccc')
uni.$u.route({ uni.$u.route({
url: 'pages/record-content/index', url: 'pages/record-content/index',
params: { params: {
parent_id: this.query.id, parent_id: this.query.id,
detail_id: item.id, detail_id: item.id,
}, },
}); })
}, },
getIsFirstRecordType() { getIsFirstRecordType() {
let isFirstRecordType = uni.getStorageSync('isFirstRecordType'); let isFirstRecordType = uni.getStorageSync('isFirstRecordType')
if (!isFirstRecordType){ if (!isFirstRecordType) {
uni.setStorageSync('isFirstRecordType', 1); uni.setStorageSync('isFirstRecordType', 1)
isFirstRecordType = uni.getStorageSync('isFirstRecordType'); isFirstRecordType = uni.getStorageSync('isFirstRecordType')
} }
return isFirstRecordType; return isFirstRecordType
}, },
}, },
}; }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -2,7 +2,7 @@ export const iconType = new Map([ ...@@ -2,7 +2,7 @@ export const iconType = new Map([
[10, '交通违法'], [10, '交通违法'],
[20, '不文明'], [20, '不文明'],
[30, '设施故障'], [30, '设施故障'],
]); ])
export const iconList = [ export const iconList = [
{ {
...@@ -197,4 +197,4 @@ export const iconList = [ ...@@ -197,4 +197,4 @@ export const iconList = [
name: '渣土车', name: '渣土车',
icon: '/static/record-icon/ic_hjbh_7@2x.png', icon: '/static/record-icon/ic_hjbh_7@2x.png',
}, },
]; ]
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
</u-modal> </u-modal>
--> -->
</view> </view>
</view> </view>
</template> </template>
...@@ -53,7 +52,7 @@ const _list = [ ...@@ -53,7 +52,7 @@ const _list = [
icon: '/static/icon/ic-gz@2x.png', icon: '/static/icon/ic-gz@2x.png',
background: 'linear-gradient(156deg,#ffdc8b 0%, #ffb00d 100%)', background: 'linear-gradient(156deg,#ffdc8b 0%, #ffb00d 100%)',
}, },
]; ]
const faultName = '交通设施故障上报' const faultName = '交通设施故障上报'
...@@ -71,20 +70,20 @@ export default { ...@@ -71,20 +70,20 @@ export default {
faultTask: { id: 0, parent: { id: 0 } }, faultTask: { id: 0, parent: { id: 0 } },
activeItem: {}, activeItem: {},
modalShow: false, modalShow: false,
}; }
}, },
computed: { computed: {
modalHeight() { modalHeight() {
// console.log(innerHeight); // console.log(innerHeight);
return Math.ceil(window.innerHeight * 2 * 0.6); return Math.ceil(window.innerHeight * 2 * 0.6)
}, },
}, },
onLoad(query) { onLoad(query) {
this.fetchPhotoTaskTypeData(); this.fetchPhotoTaskTypeData()
// this.fetchPhotoTaskTypeDetail(); // this.fetchPhotoTaskTypeDetail();
this.isFirstRecord = this.getIsFirstRecord(); this.isFirstRecord = this.getIsFirstRecord()
// console.log(this.isFirstRecord); // console.log(this.isFirstRecord);
}, },
...@@ -92,49 +91,54 @@ export default { ...@@ -92,49 +91,54 @@ export default {
methods: { methods: {
async fetchPhotoTaskTypeData() { async fetchPhotoTaskTypeData() {
const { list } = await uni.$u.http.get('/api/app/phototasktype/list', { params: { parent_id: 0 } }); const { list } = await uni.$u.http.get('/api/app/phototasktype/list', { params: { parent_id: 0 } })
this.list = list.map((value, index) => ({ ...value, background: _list[index].background })); this.list = list.map((value, index) => ({ ...value, background: _list[index].background }))
const fault = this.list.find(v => v.name === faultName) const fault = this.list.find((v) => v.name === faultName)
this.fetchFalutTask(fault.id) this.fetchFalutTask(fault.id)
}, },
async fetchPhotoTaskTypeDetail() { async fetchPhotoTaskTypeDetail() {
const { detail } = await uni.$u.http.get('/api/app/phototasktype/detail', { params: { id: 0 } }); const { detail } = await uni.$u.http.get('/api/app/phototasktype/detail', { params: { id: 0 } })
// console.log(detail); // console.log(detail);
}, },
async fetchFalutTask(id) { async fetchFalutTask(id) {
const { list: [task] } = await uni.$u.http.get('/api/app/phototasktype/list', { params: { parent_id: id } }) const {
list: [task],
} = await uni.$u.http.get('/api/app/phototasktype/list', { params: { parent_id: id } })
this.faultTask = task this.faultTask = task
}, },
async onReportClick() { async onReportClick() {
console.log('onReportClick'); console.log('onReportClick')
this.showReport = true; this.showReport = true
}, },
async onReportConfirm() { async onReportConfirm() {
if (!this.isFirstRecord) { if (!this.isFirstRecord) {
this.showReport = false; this.showReport = false
this.isFirstRecord = this.getIsFirstRecord(); this.isFirstRecord = this.getIsFirstRecord()
uni.$u.route({ url: 'pages/record-type/index', params: { id: this.isFirstRecordId } }); uni.$u.route({ url: 'pages/record-type/index', params: { id: this.isFirstRecordId } })
} }
this.showReport = false; this.showReport = false
}, },
_onListClick(item, index) { _onListClick(item, index) {
const { name } = item const { name } = item
// 交通设施故障上报直接进入填写表单 // 交通设施故障上报直接进入填写表单
if (name === faultName) { if (name === faultName) {
const { id, parent: { id: parentId } } = this.faultTask const {
id,
parent: { id: parentId },
} = this.faultTask
uni.$u.route({ uni.$u.route({
url: 'pages/record-content/index', url: 'pages/record-content/index',
params: { params: {
parent_id: parentId, parent_id: parentId,
detail_id: id, detail_id: id,
}, },
}); })
return return
} }
this.activeItem = item this.activeItem = item
...@@ -145,37 +149,35 @@ export default { ...@@ -145,37 +149,35 @@ export default {
// console.log(this.isFirstRecord); // console.log(this.isFirstRecord);
if (!this.isFirstRecord) { if (!this.isFirstRecord) {
// console.log(123); // console.log(123);
this.isFirstRecordId = item.id; this.isFirstRecordId = item.id
this.showReport = true; this.showReport = true
return; return
} }
// console.log(123,'ttc'); // console.log(123,'ttc');
uni.$u.route({ url: 'pages/record-type/index', uni.$u.route({
url: 'pages/record-type/index',
params: { params: {
id: item.id, id: item.id,
} ,
});
}, },
})
},
getIsFirstRecord() { getIsFirstRecord() {
let isFirstRecord = uni.getStorageSync('isFirstRecord'); let isFirstRecord = uni.getStorageSync('isFirstRecord')
if (!isFirstRecord){ if (!isFirstRecord) {
uni.setStorageSync('isFirstRecord', 1) uni.setStorageSync('isFirstRecord', 1)
isFirstRecord = uni.getStorageSync('isFirstRecord'); isFirstRecord = uni.getStorageSync('isFirstRecord')
} ; }
return isFirstRecord; return isFirstRecord
}, },
onModalConfirm() { onModalConfirm() {
this.modalShow = false this.modalShow = false
this.onListClick(this.activeItem) this.onListClick(this.activeItem)
}
}, },
}; },
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -22,32 +22,32 @@ $uni-color-warning: #f0ad4e; ...@@ -22,32 +22,32 @@ $uni-color-warning: #f0ad4e;
$uni-color-error: #dd524d; $uni-color-error: #dd524d;
/* 文字基本颜色 */ /* 文字基本颜色 */
$uni-text-color:#333;//基本色 $uni-text-color: #333; //基本色
$uni-text-color-inverse:#fff;//反色 $uni-text-color-inverse: #fff; //反色
$uni-text-color-grey:#999;//辅助灰色,如加载更多的提示信息 $uni-text-color-grey: #999; //辅助灰色,如加载更多的提示信息
$uni-text-color-placeholder: #808080; $uni-text-color-placeholder: #808080;
$uni-text-color-disable:#c0c0c0; $uni-text-color-disable: #c0c0c0;
/* 背景颜色 */ /* 背景颜色 */
$uni-bg-color:#ffffff; $uni-bg-color: #ffffff;
$uni-bg-color-grey:#f8f8f8; $uni-bg-color-grey: #f8f8f8;
$uni-bg-color-hover:#f1f1f1;//点击状态颜色 $uni-bg-color-hover: #f1f1f1; //点击状态颜色
$uni-bg-color-mask:rgba(0, 0, 0, 0.4);//遮罩颜色 $uni-bg-color-mask: rgba(0, 0, 0, 0.4); //遮罩颜色
/* 边框颜色 */ /* 边框颜色 */
$uni-border-color:#c8c7cc; $uni-border-color: #c8c7cc;
/* 尺寸变量 */ /* 尺寸变量 */
/* 文字尺寸 */ /* 文字尺寸 */
$uni-font-size-sm:12px; $uni-font-size-sm: 12px;
$uni-font-size-base:14px; $uni-font-size-base: 14px;
$uni-font-size-lg:16; $uni-font-size-lg: 16;
/* 图片尺寸 */ /* 图片尺寸 */
$uni-img-size-sm:20px; $uni-img-size-sm: 20px;
$uni-img-size-base:26px; $uni-img-size-base: 26px;
$uni-img-size-lg:40px; $uni-img-size-lg: 40px;
/* Border Radius */ /* Border Radius */
$uni-border-radius-sm: 2px; $uni-border-radius-sm: 2px;
...@@ -69,9 +69,9 @@ $uni-spacing-col-lg: 12px; ...@@ -69,9 +69,9 @@ $uni-spacing-col-lg: 12px;
$uni-opacity-disabled: 0.3; // 组件禁用态的透明度 $uni-opacity-disabled: 0.3; // 组件禁用态的透明度
/* 文章场景相关 */ /* 文章场景相关 */
$uni-color-title: #2C405A; // 文章标题颜色 $uni-color-title: #2c405a; // 文章标题颜色
$uni-font-size-title:20px; $uni-font-size-title: 20px;
$uni-color-subtitle: #555555; // 二级标题颜色 $uni-color-subtitle: #555555; // 二级标题颜色
$uni-font-size-subtitle:26px; $uni-font-size-subtitle: 26px;
$uni-color-paragraph: #3F536E; // 文章段落颜色 $uni-color-paragraph: #3f536e; // 文章段落颜色
$uni-font-size-paragraph:15px; $uni-font-size-paragraph: 15px;
import Vue from 'vue'; import Vue from 'vue'
const request = uni.$u.http; const request = uni.$u.http
const noMoreStatus = 'nomore'; const noMoreStatus = 'nomore'
const get = request.get.bind(request); const get = request.get.bind(request)
const createList = (config = {}) => ({ const createList = (config = {}) => ({
requesting: false, requesting: false,
...@@ -10,54 +10,54 @@ const createList = (config = {}) => ({ ...@@ -10,54 +10,54 @@ const createList = (config = {}) => ({
page: 0, page: 0,
data: [], data: [],
...config, ...config,
}); })
const getStatus = (res) => { const getStatus = (res) => {
const { has_next: hasNext, total_count: total } = res; const { has_next: hasNext, total_count: total } = res
return total === 0 ? 'empty' : hasNext ? 'loading' : noMoreStatus; return total === 0 ? 'empty' : hasNext ? 'loading' : noMoreStatus
}; }
const getList = async (context, listKey = '', req = [], options = {}) => { const getList = async (context, listKey = '', req = [], options = {}) => {
const { transform = (data) => data, mergeData, abandon = () => false, beforeSetData = () => {}, callback = () => {} } = options; const { transform = (data) => data, mergeData, abandon = () => false, beforeSetData = () => {}, callback = () => {} } = options
const getTarget = () => context[listKey]; const getTarget = () => context[listKey]
const list = getTarget(); const list = getTarget()
const setList = (value) => Vue.set(context, listKey, value); const setList = (value) => Vue.set(context, listKey, value)
const setKey = (key, value) => Vue.set(getTarget(), key, value); const setKey = (key, value) => Vue.set(getTarget(), key, value)
if (list.requesting || list.status === noMoreStatus) return; if (list.requesting || list.status === noMoreStatus) return
setKey('requesting', true); setKey('requesting', true)
const newPage = list.page + 1; const newPage = list.page + 1
try { try {
let res; let res
if (req instanceof Promise) { if (req instanceof Promise) {
res = await req; res = await req
} else { } else {
const [url, data, ...restParams] = Array.isArray(req) ? req : [req]; const [url, data, ...restParams] = Array.isArray(req) ? req : [req]
const params = { page: newPage, page_num: newPage, ...data }; const params = { page: newPage, page_num: newPage, ...data }
res = await get(url, { params }, ...restParams); res = await get(url, { params }, ...restParams)
} }
if (abandon()) return; if (abandon()) return
const newListData = transform(res.list); const newListData = transform(res.list)
const newList = { const newList = {
...list, ...list,
total: res.total_count, total: res.total_count,
status: getStatus(res), status: getStatus(res),
page: newPage, page: newPage,
data: mergeData ? mergeData(list.data, newListData) : newPage === 1 ? newListData : [...list.data, ...newListData], data: mergeData ? mergeData(list.data, newListData) : newPage === 1 ? newListData : [...list.data, ...newListData],
}; }
beforeSetData(); beforeSetData()
setList(newList); setList(newList)
return Promise.resolve(res); return Promise.resolve(res)
} catch (e) { } catch (e) {
console.error('getList:', e); console.error('getList:', e)
setList({ ...list, status: 'error' }); setList({ ...list, status: 'error' })
} finally { } finally {
setKey('requesting', false); setKey('requesting', false)
} }
}; }
export { createList, getList }; export { createList, getList }
...@@ -2,41 +2,41 @@ ...@@ -2,41 +2,41 @@
module.exports = (vm) => { module.exports = (vm) => {
// 初始化请求配置 // 初始化请求配置
uni.$u.http.setConfig((config) => { uni.$u.http.setConfig((config) => {
return config; return config
}); })
// 请求拦截 // 请求拦截
uni.$u.http.interceptors.request.use( uni.$u.http.interceptors.request.use(
(config) => { (config) => {
config.data = config.data || {}; config.data = config.data || {}
config.params.token = 'd957a00e9a9834b7fda7578f334cb67e'; config.params.token = 'd957a00e9a9834b7fda7578f334cb67e'
return config; return config
}, },
(config) => { (config) => {
return Promise.reject(config); return Promise.reject(config)
} }
); )
// 响应拦截 // 响应拦截
uni.$u.http.interceptors.response.use( uni.$u.http.interceptors.response.use(
(response) => { (response) => {
const data = response.data; const data = response.data
if (data.errcode) { if (data.errcode) {
if (data.errcode === 302) { if (data.errcode === 302) {
uni.$u.toast(data.msg); uni.$u.toast(data.msg)
window.location.href = data.data.location; window.location.href = data.data.location
return Promise.reject(response); return Promise.reject(response)
} }
uni.$u.toast(data.msg); uni.$u.toast(data.msg)
return Promise.reject(response); return Promise.reject(response)
} }
return data.data === undefined ? {} : data.data; return data.data === undefined ? {} : data.data
}, },
(response) => { (response) => {
// 对响应错误做点什么 (statusCode !== 200) // 对响应错误做点什么 (statusCode !== 200)
return Promise.reject(response); return Promise.reject(response)
} }
); )
}; }
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
// const baseURL = 'http://192.168.50.242:8026'; // const baseURL = 'http://192.168.50.242:8026';
// 向外暴露一个方法 myRequest // 向外暴露一个方法 myRequest
export const myRequest = (options) => { export const myRequest = (options) => {
let headers = {}; let headers = {}
// headers["Content-Type"] = "multipart/form-data"; // headers["Content-Type"] = "multipart/form-data";
headers['Content-Type'] = 'application/json'; headers['Content-Type'] = 'application/json'
// headers["Content-Type"] = "application/x-www-form-urlencoded"; // headers["Content-Type"] = "application/x-www-form-urlencoded";
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
...@@ -22,116 +22,116 @@ export const myRequest = (options) => { ...@@ -22,116 +22,116 @@ export const myRequest = (options) => {
success: (res) => { success: (res) => {
// 此判断可根据自己需要更改 // 此判断可根据自己需要更改
if (res.statusCode == 500) { if (res.statusCode == 500) {
reject(res); reject(res)
return uni.showToast({ return uni.showToast({
title: '网络错误!', title: '网络错误!',
icon: 'none', icon: 'none',
}); })
} }
resolve(res); resolve(res)
}, },
// 请求失败 // 请求失败
fail: (err) => { fail: (err) => {
uni.showToast({ uni.showToast({
title: '请求接口失败!', title: '请求接口失败!',
icon: 'none', icon: 'none',
}); })
reject(err); reject(err)
}, },
//请求结束之后,执行的回调函数(成功或失败都会执行) //请求结束之后,执行的回调函数(成功或失败都会执行)
complete() { complete() {
//隐藏loading //隐藏loading
// uni.hideLoading() // uni.hideLoading()
}, },
}); })
}); })
}; }
export const getPrice = (value = 0) => Number(value ?? 0) / 100; export const getPrice = (value = 0) => Number(value ?? 0) / 100
// 复制 // 复制
export const myCopy = (txt = '') => { export const myCopy = (txt = '') => {
const input = document.createElement('input'); // 创建一个新input标签 const input = document.createElement('input') // 创建一个新input标签
input.setAttribute('readonly', 'readonly'); // 设置input标签只读属性 input.setAttribute('readonly', 'readonly') // 设置input标签只读属性
input.setAttribute('value', txt); // 设置input value值为需要复制的内容 input.setAttribute('value', txt) // 设置input value值为需要复制的内容
document.body.appendChild(input); // 添加input标签到页面 document.body.appendChild(input) // 添加input标签到页面
input.select(); // 选中input内容 input.select() // 选中input内容
input.setSelectionRange(0, 9999); // 设置选中input内容范围 input.setSelectionRange(0, 9999) // 设置选中input内容范围
document.execCommand('copy'); // 复制 document.execCommand('copy') // 复制
document.body.removeChild(input); // 删除新创建的input标签 document.body.removeChild(input) // 删除新创建的input标签
//此处可以设置一个弹窗提示 //此处可以设置一个弹窗提示
uni.$u.toast('复制成功'); uni.$u.toast('复制成功')
}; }
// 图片水印 // 图片水印
const base64_encode = (str) => { const base64_encode = (str) => {
// 下面是64个基本的编码 // 下面是64个基本的编码
const base64EncodeChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; const base64EncodeChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
let out; let out
let i; let i
let len; let len
let c1; let c1
let c2; let c2
let c3; let c3
len = str.length; len = str.length
i = 0; i = 0
out = ''; out = ''
while (i < len) { while (i < len) {
c1 = str.charCodeAt(i++) & 0xff; c1 = str.charCodeAt(i++) & 0xff
if (i === len) { if (i === len) {
out += base64EncodeChars.charAt(c1 >> 2); out += base64EncodeChars.charAt(c1 >> 2)
out += base64EncodeChars.charAt((c1 & 0x3) << 4); out += base64EncodeChars.charAt((c1 & 0x3) << 4)
out += '=='; out += '=='
break; break
} }
c2 = str.charCodeAt(i++); c2 = str.charCodeAt(i++)
if (i === len) { if (i === len) {
out += base64EncodeChars.charAt(c1 >> 2); out += base64EncodeChars.charAt(c1 >> 2)
out += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xf0) >> 4)); out += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xf0) >> 4))
out += base64EncodeChars.charAt((c2 & 0xf) << 2); out += base64EncodeChars.charAt((c2 & 0xf) << 2)
out += '='; out += '='
break; break
} }
c3 = str.charCodeAt(i++); c3 = str.charCodeAt(i++)
out += base64EncodeChars.charAt(c1 >> 2); out += base64EncodeChars.charAt(c1 >> 2)
out += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xf0) >> 4)); out += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xf0) >> 4))
out += base64EncodeChars.charAt(((c2 & 0xf) << 2) | ((c3 & 0xc0) >> 6)); out += base64EncodeChars.charAt(((c2 & 0xf) << 2) | ((c3 & 0xc0) >> 6))
out += base64EncodeChars.charAt(c3 & 0x3f); out += base64EncodeChars.charAt(c3 & 0x3f)
} }
return out; return out
}; }
const utf16to8 = (str) => { const utf16to8 = (str) => {
let out; let out
let i; let i
let len; let len
let c; let c
out = ''; out = ''
len = str.length; len = str.length
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
c = str.charCodeAt(i); c = str.charCodeAt(i)
if (c >= 0x0001 && c <= 0x007f) { if (c >= 0x0001 && c <= 0x007f) {
out += str.charAt(i); out += str.charAt(i)
} else if (c > 0x07ff) { } else if (c > 0x07ff) {
out += String.fromCharCode(0xe0 | ((c >> 12) & 0x0f)); out += String.fromCharCode(0xe0 | ((c >> 12) & 0x0f))
out += String.fromCharCode(0x80 | ((c >> 6) & 0x3f)); out += String.fromCharCode(0x80 | ((c >> 6) & 0x3f))
out += String.fromCharCode(0x80 | ((c >> 0) & 0x3f)); out += String.fromCharCode(0x80 | ((c >> 0) & 0x3f))
} else { } else {
out += String.fromCharCode(0xc0 | ((c >> 6) & 0x1f)); out += String.fromCharCode(0xc0 | ((c >> 6) & 0x1f))
out += String.fromCharCode(0x80 | ((c >> 0) & 0x3f)); out += String.fromCharCode(0x80 | ((c >> 0) & 0x3f))
} }
} }
return out; return out
}; }
export const baseEncode = (str) => { export const baseEncode = (str) => {
return base64_encode(utf16to8(str)); return base64_encode(utf16to8(str))
}; }
export const getImageInfo = src => { export const getImageInfo = (src) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
uni.getImageInfo({ src, success: resolve, fail: reject }) uni.getImageInfo({ src, success: resolve, fail: reject })
}) })
} }
export default myRequest; export default myRequest
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论