裂变星小程序-25.03.04
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

327 lines
8.6 KiB

2 months ago
2 months ago
2 months ago
2 months ago
  1. <template>
  2. <view class="page">
  3. <navbar title="分享记录" />
  4. <view class="content">
  5. <view class="card" style="padding-left: 0; padding-right: 10rpx;">
  6. <uv-tabs :list="tabs" @click="clickTabs" :inactiveStyle="{
  7. color: '#999999',
  8. fontSize: '30rpx',
  9. fontWeight: 500,
  10. whiteSpace: 'nowrap',
  11. }" :activeStyle="{
  12. color: '#1B1B1B',
  13. fontSize: '38rpx',
  14. fontWeight: 900,
  15. whiteSpace: 'nowrap',
  16. }" lineHeight="13rpx" lineWidth="77rpx" :lineColor="`url(${sliderBgUrl}) 100% 100%`" :scrollable="false">
  17. <template v-slot:right>
  18. <suspendDropdown v-model="status" :options="auditStatusOptions" @change="onAuditStatusChange">
  19. </suspendDropdown>
  20. </template>
  21. </uv-tabs>
  22. </view>
  23. <view v-if="!isLoggedIn" class="card login-tip">
  24. <view class="login-tip-text">登录后查看分享记录</view>
  25. <button class="btn-login" @click="goToLogin">立即登录</button>
  26. </view>
  27. <view v-else-if="list.length" class="card list">
  28. <view class="list-item" v-for="item in list" @click="toSharingDetail(item.id)" :key="item.id">
  29. <!-- todo: video? -->
  30. <image class="left" :src="item.indexImage || item.headImage"></image>
  31. <view class="right">
  32. <view class="title">{{ item.headTitle || '' }}</view>
  33. <view class="desc">{{ item.textDetails || '' }}</view>
  34. <view class="bottom">
  35. <text class="desc">{{ item.createTime || '' }}</text>
  36. <button plain class="btn-simple btn-delete flex" @click.stop="onDelete(item.id)">
  37. <image src="../../static/image/record/delete.png" style="width: 24rpx; height: 24rpx;">
  38. </image>
  39. <text style="margin-left: 10rpx;">删除</text>
  40. </button>
  41. </view>
  42. <view class="mark">
  43. <image :src="auditStatusImgMapping[item.status]" style="width: 100rpx; height: 100rpx;">
  44. </image>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <!-- todo: empty -->
  50. </view>
  51. <popupActivate ref="popupActivate"></popupActivate>
  52. <tabber select="record" />
  53. </view>
  54. </template>
  55. <script>
  56. import { mapGetters } from 'vuex'
  57. import mixinsList from '@/mixins/list.js'
  58. import tabber from '@/components/base/tabbar.vue'
  59. import suspendDropdown from '@/components/base/suspendDropdown.vue'
  60. import popupActivate from '@/components/center/popupActivate.vue'
  61. const URL_MAPPING = { // state -> url
  62. '0': '/pages_order/record/personalSharing',
  63. '1': '/pages_order/record/videoSharing',
  64. '2': '/pages_order/record/groupSharing',
  65. '3': '/pages_order/record/articleSharing',
  66. }
  67. export default {
  68. mixins: [mixinsList],
  69. components: {
  70. tabber,
  71. suspendDropdown,
  72. popupActivate,
  73. },
  74. computed: {
  75. ...mapGetters(['userShop']),
  76. },
  77. data() {
  78. return {
  79. tabs: [{
  80. name: '个人分享'
  81. },
  82. {
  83. name: '视频分享'
  84. },
  85. {
  86. name: '群分享'
  87. },
  88. {
  89. name: '文章分享'
  90. },
  91. ],
  92. auditStatusOptions: [
  93. {
  94. label: '审核中',
  95. value: 0,
  96. },
  97. {
  98. label: '已通过',
  99. value: 1,
  100. },
  101. {
  102. label: '未通过',
  103. value: 2,
  104. },
  105. ],
  106. queryParams: {
  107. pageNo: 1,
  108. pageSize: 10,
  109. state: 0,
  110. },
  111. status: null,
  112. recordList: { // 列表数据
  113. records: [],
  114. total: 0,
  115. },
  116. auditStatusImgMapping: {
  117. 0: '../../static/image/record/audit.png', // 审核中
  118. 1: '../../static/image/record/pass.png', // 已通过
  119. 2: '../../static/image/record/fail.png', // 未通过
  120. },
  121. // todo
  122. sliderBgUrl: '',
  123. mixinsListApi: 'getSharePage',
  124. authApi : true,
  125. isLoggedIn : uni.getStorageSync('token'),
  126. }
  127. },
  128. onShow(){
  129. this.isLoggedIn = uni.getStorageSync('token')
  130. },
  131. methods: {
  132. //点击tab栏
  133. clickTabs(e) {
  134. if (!this.isLoggedIn) {
  135. this.goToLogin()
  136. return
  137. }
  138. this.queryParams.state = e.index
  139. this.queryParams.pageNo = 1
  140. this.queryParams.pageSize = 10
  141. this.getData()
  142. },
  143. onAuditStatusChange(status) {
  144. if (!this.isLoggedIn) {
  145. this.goToLogin()
  146. return
  147. }
  148. this.status = status
  149. this.queryParams.pageNo = 1
  150. this.queryParams.pageSize = 10
  151. if (status === null) {
  152. delete this.queryParams.status
  153. } else {
  154. this.queryParams.status = status
  155. }
  156. this.getData()
  157. },
  158. //跳转分享详情页面
  159. toSharingDetail(id) {
  160. if (!this.isLoggedIn) {
  161. this.goToLogin()
  162. return
  163. }
  164. if (!this.userInfo.isPay) {
  165. this.$refs.popupActivate.open()
  166. return
  167. }
  168. uni.navigateTo({
  169. url: `${URL_MAPPING[this.queryParams.state]}?id=${id}`
  170. })
  171. },
  172. onDelete(id) {
  173. if (!this.isLoggedIn) {
  174. this.goToLogin()
  175. return
  176. }
  177. uni.showModal({
  178. title: '确认删除该分享吗',
  179. success: async (r) => {
  180. if (r.confirm) {
  181. await this.$fetch('deleteLog', { id, state: this.queryParams.state })
  182. this.getData()
  183. }
  184. }
  185. })
  186. },
  187. goToLogin() {
  188. uni.navigateTo({
  189. url: '/pages_order/auth/wxLogin'
  190. })
  191. },
  192. }
  193. }
  194. </script>
  195. <style scoped lang="scss">
  196. .page {}
  197. .content {
  198. padding: 20rpx;
  199. }
  200. .list {
  201. margin-top: 20rpx;
  202. padding: 40rpx 59rpx 40rpx 43rpx;
  203. &-item {
  204. font-size: 0;
  205. display: flex;
  206. &+& {
  207. margin-top: 40rpx;
  208. }
  209. .left {
  210. width: 220rpx;
  211. height: 148rpx;
  212. }
  213. .right {
  214. flex: 1;
  215. width: calc(100% - 220rpx);
  216. padding-left: 20rpx;
  217. box-sizing: border-box;
  218. position: relative;
  219. }
  220. }
  221. .title {
  222. color: #1B1B1B;
  223. font-size: 28rpx;
  224. overflow:hidden; //超出的文本隐藏
  225. text-overflow:ellipsis; //溢出用省略号显示
  226. white-space:nowrap; //溢出不换行
  227. }
  228. .desc {
  229. color: #999999;
  230. font-size: 24rpx;
  231. white-space: nowrap;
  232. overflow: hidden;
  233. text-overflow: ellipsis;
  234. text-align: left;
  235. }
  236. .title+.desc {
  237. margin-top: 18rpx;
  238. }
  239. .bottom {
  240. position: absolute;
  241. bottom: 0;
  242. width: calc(100% - 20rpx);
  243. }
  244. .btn-delete {
  245. float: right;
  246. color: #05D9A2;
  247. font-size: 20rpx;
  248. }
  249. .mark {
  250. position: absolute;
  251. top: 10rpx;
  252. right: 5rpx;
  253. }
  254. }
  255. .popup {
  256. &-options {
  257. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);
  258. padding: 16rpx 40rpx;
  259. }
  260. &-option {
  261. color: #999999;
  262. font-size: 28rpx;
  263. &.is-active {
  264. color: #1B1B1B;
  265. font-weight: 700;
  266. }
  267. &+& {
  268. margin-top: 16rpx;
  269. }
  270. }
  271. }
  272. .login-tip {
  273. margin-top: 20rpx;
  274. padding: 40rpx;
  275. text-align: center;
  276. &-text {
  277. color: #999999;
  278. font-size: 28rpx;
  279. margin-bottom: 20rpx;
  280. }
  281. }
  282. .btn-login {
  283. width: 240rpx;
  284. height: 80rpx;
  285. line-height: 80rpx;
  286. background: #04D6A3;
  287. color: #FFFFFF;
  288. font-size: 28rpx;
  289. border-radius: 40rpx;
  290. margin: 0 auto;
  291. }
  292. </style>