Browse Source

优化不适用的文件

master
453530270@qq.com 2 years ago
parent
commit
05aa460aaa
  1. 47
      api/order.js
  2. 18
      api/upload.js
  3. 188
      pages.json
  4. 187
      pages/address/create.vue
  5. 309
      pages/address/index.vue
  6. 225
      pages/address/update.vue
  7. 107
      pages/article/detail.vue
  8. 251
      pages/article/index.vue

47
api/order.js

@ -0,0 +1,47 @@
import request from '@/utils/request'
// api地址
const api = {
todoCounts: 'order/todoCounts',
list: 'order/list',
detail: 'order/detail',
express: 'order/express',
cancel: 'order/cancel',
receipt: 'order/receipt',
pay: 'order/pay'
}
// 当前用户待处理的订单数量
export function todoCounts(param, option) {
return request.get(api.todoCounts, param, option)
}
// 我的订单列表
export function list(param, option) {
return request.get(api.list, param, option)
}
// 订单详情
export function detail(orderId, param) {
return request.get(api.detail, { orderId, ...param })
}
// 获取物流信息
export function express(orderId, param) {
return request.get(api.express, { orderId, ...param })
}
// 取消订单
export function cancel(orderId, data) {
return request.post(api.cancel, { orderId, ...data })
}
// 确认收货
export function receipt(orderId, data) {
return request.post(api.receipt, { orderId, ...data })
}
// 立即支付
export function pay(orderId, payType, param) {
return request.get(api.pay, { orderId, payType, ...param })
}

18
api/upload.js

@ -0,0 +1,18 @@
import request from '@/utils/request'
// api地址
const api = {
image: 'upload/image'
}
// 图片上传
export const image = files => {
// 文件上传大小, 2M
const maxSize = 1024 * 1024 * 2
// 执行上传
return new Promise((resolve, reject) => {
request.urlFileUpload({ files, maxSize })
.then(result => resolve(result.map(item => item.data.fileInfo.file_id), result))
.catch(reject)
})
}

188
pages.json

@ -14,17 +14,7 @@
"iconPath": "static/tabbar/cate.png",
"selectedIconPath": "static/tabbar/cate-active.png",
"text": "分类"
}, {
"pagePath": "pages/cart/index",
"iconPath": "static/tabbar/cart.png",
"selectedIconPath": "static/tabbar/cart-active.png",
"text": "购物车"
}, {
"pagePath": "pages/user/index",
"iconPath": "static/tabbar/user.png",
"selectedIconPath": "static/tabbar/user-active.png",
"text": "我的"
}]
} ]
},
"pages": [ //pageshttps://uniapp.dcloud.io/collocation/pages
{
@ -33,18 +23,6 @@
"enablePullDownRefresh": true
}
},
{
"path": "pages/category/index",
"style": {
"navigationBarTitleText": "全部分类"
}
},
{
"path": "pages/cart/index",
"style": {
"navigationBarTitleText": "购物车"
}
},
{
"path": "pages/user/index",
"style": {
@ -53,18 +31,8 @@
"navigationStyle": "custom"
}
},
{
"path": "pages/custom/index",
"style": {
"enablePullDownRefresh": true
}
},
{
"path": "pages/search/index",
"style": {
"navigationBarTitleText": "商品搜索"
}
},
{
"path": "pages/login/index",
"style": {
@ -83,161 +51,13 @@
"navigationBarTitleText": "个人信息"
}
},
{
"path": "pages/article/index",
"style": {
"navigationBarTitleText": "资讯列表"
}
},
{
"path": "pages/article/detail",
"style": {
"navigationBarTitleText": "资讯详情"
}
},
{
"path": "pages/help/index",
"style": {
"navigationBarTitleText": "帮助中心"
}
},
{
"path": "pages/coupon/index",
"style": {
"navigationBarTitleText": "领券中心"
}
},
{
"path": "pages/goods/list",
"style": {
"navigationBarTitleText": "商品列表",
"enablePullDownRefresh": true
}
},
{
"path": "pages/goods/detail",
"style": {
"navigationBarTitleText": "商品详情页"
}
},
{
"path": "pages/comment/index",
"style": {
"navigationBarTitleText": "商品评价页"
}
},
{
"path": "pages/my-coupon/index",
"style": {
"navigationBarTitleText": "我的优惠券"
}
},
{
"path": "pages/address/index",
"style": {
"navigationBarTitleText": "收货地址"
}
},
{
"path": "pages/address/create",
"style": {
"navigationBarTitleText": "新增收货地址"
}
},
{
"path": "pages/address/update",
"style": {
"navigationBarTitleText": "编辑收货地址"
}
},
{
"path": "pages/points/log",
"style": {
"navigationBarTitleText": "账单明细"
}
},
{
"path": "pages/wallet/index",
"style": {
"navigationBarTitleText": "我的钱包"
}
},
{
"path": "pages/wallet/balance/log",
"style": {
"navigationBarTitleText": "账单详情"
}
},
{
"path": "pages/wallet/recharge/index",
"style": {
"navigationBarTitleText": "充值中心"
}
},
{
"path": "pages/wallet/recharge/order",
"style": {
"navigationBarTitleText": "充值记录"
}
},
{
"path": "pages/checkout/index",
"style": {
"navigationBarTitleText": "订单结算台"
}
},
{
"path": "pages/order/center",
"style": {
"navigationBarTitleText": "订单中心",
"enablePullDownRefresh": true
}
},
{
"path": "pages/order/index",
"style": {
"navigationBarTitleText": "我的订单",
"enablePullDownRefresh": true
}
},
{
"path": "pages/order/detail",
"style": {
"navigationBarTitleText": "订单详情",
"navigationBarTextStyle": "white",
"navigationBarBackgroundColor": "#e8c269"
}
},
{
"path": "pages/order/express/index",
"style": {
"navigationBarTitleText": "物流跟踪"
}
},
{
"path": "pages/order/comment/index",
"style": {
"navigationBarTitleText": "订单评价"
}
},
{
"path": "pages/refund/index",
"style": {
"navigationBarTitleText": "退换/售后"
}
},
{
"path": "pages/refund/detail",
"style": {
"navigationBarTitleText": "售后详情"
}
},
{
"path": "pages/refund/apply",
"style": {
"navigationBarTitleText": "申请售后"
}
}
],
"globalStyle": {
// #ifdef H5

187
pages/address/create.vue

@ -1,187 +0,0 @@
<template>
<view class="container">
<!-- 标题 -->
<view class="page-title">收货地址</view>
<!-- 表单组件 -->
<view class="form-wrapper">
<u-form :model="form" ref="uForm" label-width="140rpx">
<u-form-item label="姓名" prop="name">
<u-input v-model="form.name" placeholder="请输入收货人姓名" />
</u-form-item>
<u-form-item label="电话" prop="phone">
<u-input v-model="form.phone" placeholder="请输入收货人手机号" />
</u-form-item>
<u-form-item label="地区" prop="region">
<select-region ref="sRegion" v-model="form.region" />
</u-form-item>
<u-form-item label="详细地址" prop="detail" :border-bottom="false">
<u-input v-model="form.detail" placeholder="街道门牌、楼层等信息" />
</u-form-item>
</u-form>
</view>
<!-- 操作按钮 -->
<view class="footer">
<view class="btn-wrapper">
<view class="btn-item btn-item-main" :class="{ disabled }" @click="handleSubmit()">保存</view>
</view>
</view>
</view>
</template>
<script>
import SelectRegion from '@/components/select-region/select-region'
import { isMobile } from '@/utils/verify'
import * as AddressApi from '@/api/address'
//
const form = {
name: '',
phone: '',
region: [],
detail: ''
}
//
const rules = {
name: [{
required: true,
message: '请输入姓名',
trigger: ['blur', 'change']
}],
phone: [{
required: true,
message: '请输入手机号',
trigger: ['blur', 'change']
}, {
//
validator: (rule, value, callback) => {
// truefalse
return isMobile(value)
},
message: '手机号码不正确',
// blurchange
trigger: ['blur'],
}],
region: [{
required: true,
message: '请选择省市区',
trigger: ['blur', 'change'],
type: 'array'
}],
detail: [{
required: true,
message: '请输入详细地址',
trigger: ['blur', 'change']
}],
}
export default {
components: {
SelectRegion
},
data() {
return {
form,
rules,
//
disabled: false
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {},
// onReadyonLoad
onReady() {
this.$refs.uForm.setRules(this.rules)
},
methods: {
//
handleSubmit() {
const app = this
if (app.disabled) {
return false
}
app.$refs.uForm.validate(valid => {
if (valid) {
app.disabled = true
AddressApi.add(app.form)
.then(result => {
app.$toast(result.message)
uni.navigateBack()
})
.finally(() => app.disabled = false)
}
})
}
}
}
</script>
<style>
page {
background: #f7f8fa;
}
</style>
<style lang="scss" scoped>
.page-title {
width: 94%;
margin: 0 auto;
padding-top: 40rpx;
font-size: 28rpx;
color: rgba(69, 90, 100, 0.6);
}
.form-wrapper {
margin: 20rpx auto 20rpx auto;
padding: 0 40rpx;
width: 94%;
box-shadow: 0 1rpx 5rpx 0px rgba(0, 0, 0, 0.05);
border-radius: 16rpx;
background: #fff;
}
//
.footer {
margin-top: 80rpx;
.btn-wrapper {
height: 100%;
// display: flex;
// align-items: center;
padding: 0 20rpx;
}
.btn-item {
flex: 1;
font-size: 28rpx;
height: 86rpx;
color: #fff;
border-radius: 50rpx;
display: flex;
justify-content: center;
align-items: center;
}
.btn-item-wechat {
background: #0ba90b;
margin-bottom: 26rpx;
}
.btn-item-main {
background: linear-gradient(to right, #f9211c, #ff6335);
color: #fff;
//
&.disabled {
opacity: 0.6;
}
}
}
</style>

309
pages/address/index.vue

@ -1,309 +0,0 @@
<template>
<view class="container">
<view class="addres-list">
<view class="address-item" v-for="(item, index) in list" :key="index">
<view class="contacts">
<text class="name">{{ item.name }}</text>
<text class="phone">{{ item.phone }}</text>
</view>
<view class="address">
<text class="region" v-for="(region, idx) in item.region" :key="idx">{{ region }}</text>
<text class="detail">{{ item.detail }}</text>
</view>
<view class="line"></view>
<view class="item-option">
<view class="_left">
<label class="item-radio" @click.stop="handleSetDefault(item.address_id)">
<radio class="radio" color="#fa2209" :checked="item.address_id == defaultId"></radio>
<text class="text">{{ item.address_id == defaultId ? '默认' : '选择' }}</text>
</label>
</view>
<view class="_right">
<view class="events">
<view class="event-item" @click="handleUpdate(item.address_id)">
<text class="iconfont icon-edit"></text>
<text class="title">编辑</text>
</view>
<view class="event-item" @click="handleRemove(item.address_id)">
<text class="iconfont icon-delete"></text>
<text class="title">删除</text>
</view>
</view>
</view>
</view>
</view>
</view>
<empty v-if="!list.length" :isLoading="isLoading" tips="亲,暂无收货地址" />
<!-- 底部操作按钮 -->
<view class="footer-fixed">
<view class="btn-wrapper">
<view class="btn-item btn-item-main" @click="handleCreate()">添加新地址</view>
</view>
</view>
</view>
</template>
<script>
import * as AddressApi from '@/api/address'
import Empty from '@/components/empty'
export default {
components: {
Empty
},
data() {
return {
//
options: {},
//
isLoading: true,
//
list: [],
//
defaultId: null
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
//
this.options = options
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
//
this.getPageData()
},
methods: {
//
getPageData() {
const app = this
app.isLoading = true
Promise.all([app.getDefaultId(), app.getAddressList()])
.then(() => {
//
app.onReorder()
})
.finally(() => app.isLoading = false)
},
//
getAddressList() {
const app = this
return new Promise((resolve, reject) => {
AddressApi.list()
.then(result => {
app.list = result.data.list
resolve(result)
})
.catch(reject)
})
},
//
getDefaultId() {
return new Promise((resolve, reject) => {
const app = this
AddressApi.defaultId()
.then(result => {
app.defaultId = result.data.defaultId
resolve(result)
})
.catch(reject)
})
},
//
onReorder() {
const app = this
app.list.sort(item => {
return item.address_id == app.defaultId ? -1 : 1
})
},
/**
* 添加新地址
*/
handleCreate() {
this.$navTo('pages/address/create')
},
/**
* 编辑地址
* @param {int} addressId 收货地址ID
*/
handleUpdate(addressId) {
this.$navTo('pages/address/update', { addressId })
},
/**
* 删除收货地址
* @param {int} addressId 收货地址ID
*/
handleRemove(addressId) {
const app = this
uni.showModal({
title: "提示",
content: "您确定要删除当前收货地址吗?",
success({ confirm }) {
confirm && app.onRemove(addressId)
}
});
},
/**
* 确认删除收货地址
* @param {int} addressId 收货地址ID
*/
onRemove(addressId) {
const app = this
AddressApi.remove(addressId)
.then(result => {
app.getPageData()
})
},
/**
* 设置为默认地址
* @param {Object} addressId
*/
handleSetDefault(addressId) {
const app = this
AddressApi.setDefault(addressId)
.then(result => {
app.defaultId = addressId
app.options.from === 'checkout' && uni.navigateBack()
})
}
}
}
</script>
<style lang="scss" scoped>
.addres-list {
padding-top: 20rpx;
// ios线
padding-bottom: calc(constant(safe-area-inset-bottom) + 140rpx);
padding-bottom: calc(env(safe-area-inset-bottom) + 140rpx);
}
//
.address-item {
margin: 20rpx auto 20rpx auto;
padding: 30rpx 40rpx;
width: 94%;
box-shadow: 0 1rpx 5rpx 0px rgba(0, 0, 0, 0.05);
border-radius: 16rpx;
background: #fff;
}
.contacts {
font-size: 30rpx;
margin-bottom: 16rpx;
.name {
margin-right: 16rpx;
}
}
.address {
font-size: 28rpx;
.region {
margin-right: 10rpx;
}
}
.line {
margin: 20rpx 0;
border-bottom: 1rpx solid #f3f3f3;
}
.item-option {
display: flex;
justify-content: space-between;
height: 48rpx;
//
.item-radio {
font-size: 28rpx;
.radio {
vertical-align: middle;
transform: scale(0.76)
}
.text {
vertical-align: middle;
}
}
//
.events {
display: flex;
align-items: center;
line-height: 48rpx;
.event-item {
font-size: 28rpx;
margin-right: 26rpx;
color: #4c4c4c;
&:last-child {
margin-right: 0;
}
.title {
margin-left: 8rpx;
}
}
}
}
//
.footer-fixed {
position: fixed;
bottom: var(--window-bottom);
left: 0;
right: 0;
min-height: 120rpx;
z-index: 11;
box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
background: #fff;
// ios线
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);
.btn-wrapper {
height: 120rpx;
display: flex;
align-items: center;
padding: 0 40rpx;
}
.btn-item {
flex: 1;
font-size: 28rpx;
height: 80rpx;
line-height: 80rpx;
text-align: center;
color: #fff;
border-radius: 50rpx;
}
.btn-item-main {
background: linear-gradient(to right, #f9211c, #ff6335);
}
}
</style>

225
pages/address/update.vue

@ -1,225 +0,0 @@
<template>
<view class="container">
<!-- 标题 -->
<view class="page-title">收货地址</view>
<!-- 表单组件 -->
<view class="form-wrapper">
<u-form :model="form" ref="uForm" label-width="140rpx">
<u-form-item label="姓名" prop="name">
<u-input v-model="form.name" placeholder="请输入收货人姓名" />
</u-form-item>
<u-form-item label="电话" prop="phone">
<u-input v-model="form.phone" placeholder="请输入收货人手机号" />
</u-form-item>
<u-form-item label="地区" prop="region">
<select-region ref="sRegion" v-model="form.region" />
</u-form-item>
<u-form-item label="详细地址" prop="detail" :border-bottom="false">
<u-input v-model="form.detail" placeholder="街道门牌、楼层等信息" />
</u-form-item>
</u-form>
</view>
<!-- 操作按钮 -->
<view class="footer">
<view class="btn-wrapper">
<view class="btn-item btn-item-main" :class="{ disabled }" @click="handleSubmit()">保存</view>
</view>
</view>
</view>
</template>
<script>
import SelectRegion from '@/components/select-region/select-region'
import { isMobile } from '@/utils/verify'
import * as AddressApi from '@/api/address'
//
const rules = {
name: [{
required: true,
message: '请输入姓名',
trigger: ['blur', 'change']
}],
phone: [{
required: true,
message: '请输入手机号',
trigger: ['blur', 'change']
}, {
//
validator: (rule, value, callback) => {
// truefalse
return isMobile(value)
},
message: '手机号码不正确',
// blurchange
trigger: ['blur'],
}],
region: [{
required: true,
message: '请选择省市区',
trigger: ['blur', 'change'],
type: 'array'
}],
detail: [{
required: true,
message: '请输入详细地址',
trigger: ['blur', 'change']
}],
}
export default {
components: {
SelectRegion
},
data() {
return {
form: {
name: '',
phone: '',
region: [],
detail: ''
},
rules,
//
isLoading: true,
//
disabled: false,
// ID
addressId: null
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad({ addressId }) {
// ID
this.addressId = addressId
//
this.getDetail()
},
// onReadyonLoad
onReady() {
this.$refs.uForm.setRules(this.rules)
},
methods: {
//
getDetail() {
const app = this
AddressApi.detail(app.addressId)
.then(result => {
const detail = result.data.detail
app.createFormData(detail)
})
},
//
createFormData(detail) {
const { form } = this
form.name = detail.name
form.phone = detail.phone
form.detail = detail.detail
form.region = this.createRegion(detail)
},
createRegion(detail) {
return [{
label: detail.region.province,
value: detail.province_id
}, {
label: detail.region.city,
value: detail.city_id
}, {
label: detail.region.region,
value: detail.region_id
}]
},
//
handleSubmit() {
const app = this
if (app.disabled) {
return false
}
app.$refs.uForm.validate(valid => {
if (valid) {
app.disabled = true
AddressApi.edit(app.addressId, app.form)
.then(result => {
app.$toast(result.message)
uni.navigateBack()
})
.finally(() => app.disabled = false)
}
})
}
}
}
</script>
<style>
page {
background: #f7f8fa;
}
</style>
<style lang="scss" scoped>
.page-title {
width: 94%;
margin: 0 auto;
padding-top: 40rpx;
font-size: 28rpx;
color: rgba(69, 90, 100, 0.6);
}
.form-wrapper {
margin: 20rpx auto 20rpx auto;
padding: 0 40rpx;
width: 94%;
box-shadow: 0 1rpx 5rpx 0px rgba(0, 0, 0, 0.05);
border-radius: 16rpx;
background: #fff;
}
//
.footer {
margin-top: 80rpx;
.btn-wrapper {
height: 100%;
// display: flex;
// align-items: center;
padding: 0 20rpx;
}
.btn-item {
flex: 1;
font-size: 28rpx;
height: 86rpx;
color: #fff;
border-radius: 50rpx;
display: flex;
justify-content: center;
align-items: center;
}
.btn-item-wechat {
background: #0ba90b;
margin-bottom: 26rpx;
}
.btn-item-main {
background: linear-gradient(to right, #f9211c, #ff6335);
color: #fff;
//
&.disabled {
opacity: 0.6;
}
}
}
</style>

107
pages/article/detail.vue

@ -1,107 +0,0 @@
<template>
<view v-if="!isLoading" class="container b-f p-b">
<view class="article-title">
<text class="f-32">{{ detail.title }}</text>
</view>
<view class="article-little dis-flex flex-x-between m-top10">
<view class="article-little__left">
<text class="article-views f-24 col-8">{{ detail.show_views }}次浏览</text>
</view>
<view class="article-little__right">
<text class="article-views f-24 col-8">{{ detail.view_time }}</text>
</view>
</view>
<view class="article-content m-top20">
<mp-html :content="detail.content" />
</view>
<!-- 快捷导航 -->
<shortcut />
</view>
</template>
<script>
import Shortcut from '@/components/shortcut'
import * as ArticleApi from '@/api/article'
export default {
components: {
Shortcut
},
data() {
return {
// ID
articleId: null,
//
isLoading: true,
//
detail: null
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
// ID
this.articleId = options.articleId
//
this.getArticleDetail()
},
methods: {
//
getArticleDetail() {
const app = this
app.isLoading = true
ArticleApi.detail(app.articleId)
.then(result => {
app.detail = result.data.detail
})
.finally(() => app.isLoading = false)
}
},
/**
* 分享当前页面
*/
onShareAppMessage() {
const app = this
//
const params = app.$getShareUrlParams({ articleId: app.articleId });
return {
title: app.detail.title,
path: "/pages/article/detail?" + params
}
},
/**
* 分享到朋友圈
* 本接口为 Beta 版本暂只在 Android 平台支持详见分享到朋友圈 (Beta)
* https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share-timeline.html
*/
onShareTimeline() {
const app = this
//
const params = app.$getShareUrlParams({ articleId: app.articleId });
return {
title: app.detail.title,
path: "/pages/article/detail?" + params
}
}
}
</script>
<style lang="scss" scoped>
.container {
min-height: 100vh;
padding: 20rpx;
background: #fff;
}
.article-content {
font-size: 28rpx;
}
</style>

251
pages/article/index.vue

@ -1,251 +0,0 @@
<template>
<mescroll-body ref="mescrollRef" :sticky="true" @init="mescrollInit" :down="{ use: false }" :up="upOption"
@up="upCallback">
<!-- tab栏 -->
<u-tabs :list="tabList" :is-scroll="true" :current="curTab" active-color="#fd4a5f" :duration="0.2"
@change="onChangeTab" />
<!-- 文章列表 -->
<view class="article-list">
<view class="article-item" :class="[`show-type__${item.show_type}`]" v-for="(item, index) in articleList.data"
:key="index" @click="onTargetDetail(item.article_id)">
<!-- 小图模式 -->
<block v-if="item.show_type == 10">
<view class="article-item__left flex-box">
<view class="article-item__title">
<text class="twoline-hide">{{ item.title }}</text>
</view>
<view class="article-item__footer m-top10">
<text class="article-views f-24 col-8">{{ item.show_views }}次浏览</text>
</view>
</view>
<view class="article-item__image">
<image class="image" mode="widthFix" :src="item.image_url"></image>
</view>
</block>
<!-- 大图模式 -->
<block v-if="item.show_type == 20">
<view class="article-item__title">
<text class="twoline-hide">{{ item.title }}</text>
</view>
<view class="article-item__image m-top20">
<image class="image" mode="widthFix" :src="item.image_url"></image>
</view>
<view class="article-item__footer m-top10">
<text class="article-views f-24 col-8">{{ item.show_views }}次浏览</text>
</view>
</block>
</view>
</view>
</mescroll-body>
</template>
<script>
import MescrollBody from '@/components/mescroll-uni/mescroll-body.vue'
import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins'
import * as ArticleApi from '@/api/article'
import * as CategoryApi from '@/api/article/category'
import { getEmptyPaginateObj, getMoreListData } from '@/core/app'
const pageSize = 15
export default {
components: {
MescrollBody
},
mixins: [MescrollMixin],
data() {
return {
//
tabList: [],
//
curTab: 0,
//
articleList: getEmptyPaginateObj(),
//
upOption: {
//
auto: true,
// ; 10
page: { size: pageSize },
// 3
noMoreSize: 3,
}
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
const app = this
//
app.getCategoryList(options.categoryId)
},
methods: {
/**
* 上拉加载的回调 (页面初始化时也会执行一次)
* 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10
* @param {Object} page
*/
upCallback(page) {
const app = this
//
app.getArticleList(page.num)
.then(list => {
const curPageLen = list.data.length
const totalSize = list.data.total
app.mescroll.endBySize(curPageLen, totalSize)
})
.catch(() => app.mescroll.endErr())
},
//
getCategoryList(categoryId) {
CategoryApi.list().then(result => {
this.setTabList(result.data.list, categoryId)
})
},
//
setTabList(categoryList, categoryId) {
const app = this
app.tabList = [{ value: 0, name: '全部' }]
categoryList.forEach(item => {
app.tabList.push({ value: item.category_id, name: item.name })
})
if (categoryId > 0) {
const findIndex = app.tabList.findIndex(item => item.value == categoryId)
app.curTab = findIndex > -1 ? findIndex : 0
}
},
/**
* 获取文章列表
* @param {Number} pageNo 页码
*/
getArticleList(pageNo = 1) {
const app = this
return new Promise((resolve, reject) => {
ArticleApi.list({ categoryId: app.getTabValue(), page: pageNo }, { load: false })
.then(result => {
//
const newList = result.data.list
app.articleList.data = getMoreListData(newList, app.articleList, pageNo)
resolve(newList)
})
.catch(reject)
})
},
//
onChangeTab(index) {
//
this.curTab = index
//
this.onRefreshList()
},
//
getTabValue() {
const app = this
return app.tabList.length ? app.tabList[app.curTab].value : 0
},
//
onRefreshList() {
this.articleList = getEmptyPaginateObj()
setTimeout(() => this.mescroll.resetUpScroll(), 120)
},
//
onTargetDetail(articleId) {
this.$navTo('pages/article/detail', { articleId })
}
},
/**
* 分享当前页面
*/
onShareAppMessage() {
return {
title: '文章首页',
path: "/pages/article/index?" + this.$getShareUrlParams()
}
},
/**
* 分享到朋友圈
* 本接口为 Beta 版本暂只在 Android 平台支持详见分享到朋友圈 (Beta)
* https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share-timeline.html
*/
onShareTimeline() {
return {
title: '文章首页',
path: "/pages/article/index?" + this.$getShareUrlParams()
}
}
}
</script>
<style lang="scss" scoped>
.container {
min-height: 100vh;
}
//
.article-list {
padding-top: 20rpx;
line-height: 1;
background: #f7f7f7;
}
.article-item {
margin-bottom: 20rpx;
padding: 30rpx;
background: #fff;
&:last-child {
margin-bottom: 0;
}
.article-item__title {
max-height: 74rpx;
font-size: 28rpx;
line-height: 38rpx;
color: #333;
}
.article-item__image .image {
display: block;
}
}
//
.show-type__10 {
display: flex;
.article-item__left {
padding-right: 20rpx;
}
.article-item__title {
// min-height: 72rpx;
}
.article-item__image .image {
width: 240rpx;
}
}
//
.show-type__20 .article-item__image .image {
width: 100%;
}
</style>
Loading…
Cancel
Save