store.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <template>
  2. <view class="page" v-if="!showVedio">
  3. <view class="page-header">
  4. <view class="page-header-info">
  5. <image :src="myPhoto"></image>
  6. <view class="page-header-left">
  7. <view>收藏个数:{{storge_info.user_storge_count}}个/{{storge_info.max_count}}个</view>
  8. <view>收藏空间:{{storge_info.user_storge}}/{{storge_info.max_storge}}</view>
  9. </view>
  10. </view>
  11. <view class="page-header-right">
  12. <view class="page-header-right-view1"></view>
  13. <view class="page-header-right-view2" @tap="toDetail">查看详情</view>
  14. </view>
  15. </view>
  16. <view class="page-content">
  17. <view class="footer-hr"></view>
  18. <view class="page-content-header">
  19. <view @tap="getDetail(0)">全部</view>
  20. <view>|</view>
  21. <view @tap="getDetail(4)">视频</view>
  22. <view>|</view>
  23. <view @tap="getDetail(3)">语音</view>
  24. <view>|</view>
  25. <view @tap="getDetail(2)">图片</view>
  26. <view>|</view>
  27. <view @tap="getDetail(1)">文字</view>
  28. <view>|</view>
  29. <view @tap="getDetail(11)">文件</view>
  30. <view>|</view>
  31. </view>
  32. <view class="page-content-list">
  33. <view class="page-content-item" @tap="info(item)" @longtap="openConfirm(item,index)"
  34. v-for="(item,index) in list">
  35. <view class="content-one">
  36. <!-- 图片 -->
  37. <view class="image" v-if="item.type == 2">
  38. <image class="content-one-image" :src="staticPath+ item.list_id+'/'+item.content.url">
  39. </image>
  40. <text></text>
  41. </view>
  42. <view class="voice" :class="play_id == item.id ?'play':''" v-if="item.type == 3">
  43. <view class="iconfont-im icon-yuyin-you yuyin" @tap="palyVoice(item)"></view>
  44. <view class="length">{{item.content.length}}</view>
  45. </view>
  46. <!-- 视频 -->
  47. <view class="vedio" v-if="item.type == 4">
  48. <image class="content-one-image" :src="staticPath+ item.list_id+'/'+item.content.image">
  49. </image>
  50. <image class="bubble-bofang-left" src="/static/theme/default/my/bofang.png"></image>
  51. </view>
  52. <!-- 消息 -->
  53. <view class="text-info" v-if="item.type == 1">
  54. <text>{{item.content.text}}</text>
  55. </view>
  56. <!-- 文件 -->
  57. <view v-if="item.type == 11" @tap="downFile(staticPath+ item.list_id+'/' + item.content.url)">
  58. <view class="address-flex">
  59. <view class="address-name">
  60. <text>{{item.content && item.content.name}}</text>
  61. </view>
  62. <image class="fun-icon" src="../../static/theme/default/file.png" mode="widthFix">
  63. </image>
  64. </view>
  65. </view>
  66. </view>
  67. <view class="content-two">
  68. <text>{{item.user_info.nickname}}</text>
  69. <text>{{item.time}}</text>
  70. </view>
  71. <view class="footer-hr"></view>
  72. </view>
  73. </view>
  74. </view>
  75. <uni-popup ref="popup" type="img">
  76. <uni-popup-img title="温馨提示" :beforeClose="true" content="testst" @confirm="confrim"> </uni-popup-img>
  77. </uni-popup>
  78. </view>
  79. <view v-else="showVedio" class="showVedio">
  80. <!-- <video :src="videoPath"
  81. style="height: 100%;width: 100%"
  82. id="myVideo"
  83. object-fit="fill"
  84. airplay="allow" /> -->
  85. <video autoplay="true" object-fit="fill" page-gesture="true" controls="false" style="height: 100%;width: 100%"
  86. id="myVideo" :src="videoPath">
  87. <!-- <cover-view
  88. @tap="showVedio = false"> -->
  89. <cover-image @tap="showVedio = false" src="/static/theme/default/my/close.png" class="cloneBut">
  90. </cover-image>
  91. <!-- </cover-view> -->
  92. </video>
  93. </view>
  94. </template>
  95. <script>
  96. import uniPopup from '../../components/uni-popup/uni-popup.vue';
  97. import uniPopupImg from '../../components/uni-popup/uni-popup-img.vue';
  98. import _get from "../../common/_get";
  99. import _data from "../../common/_data";
  100. import _page from "../../common/common";
  101. import {
  102. mapState,
  103. mapMutations
  104. } from 'vuex'
  105. export default {
  106. data() {
  107. return {
  108. selectIndex: 0,
  109. id: 0,
  110. play_id: '',
  111. showVedio: false,
  112. videoPath: '',
  113. storge_info: {
  114. 'user_storge_count': 0,
  115. 'user_storge': '0KB',
  116. 'max_count': '0',
  117. 'max_storge': '0KB',
  118. "user_info": {}
  119. },
  120. list: [],
  121. choose: 0, //是否是选择收藏
  122. }
  123. },
  124. components: {
  125. uniPopup,
  126. uniPopupImg
  127. },
  128. computed: {
  129. ...mapState({
  130. RECORD: state => state.audio.RECORD,
  131. AUDIO: state => state.audio.AUDIO,
  132. RecordTime: state => state.audio.RecordTime,
  133. KeyboardH: state => state.common.KeyboardHeight
  134. }),
  135. toPlay() {
  136. return this.play_id;
  137. },
  138. staticPath() {
  139. return _data.staticChat();
  140. },
  141. myPhoto() {
  142. return _data.staticPhoto() + this.storge_info.user_info.face;
  143. },
  144. },
  145. onShow() {
  146. let _this = this;
  147. _get.getUserStore({}, function(ret) {
  148. _this.storge_info = ret.info;
  149. _this.list = ret.data
  150. });
  151. },
  152. onLoad(option) {
  153. // 注册音频自然结束事件
  154. this.regVudioEndEvent((e) => {
  155. console.log('语音自然结束');
  156. this.play_id = '';
  157. });
  158. console.log("option", option);
  159. if (option.choose_collect) {
  160. this.choose = 1; //开启选择
  161. }
  162. },
  163. methods: {
  164. ...mapMutations(['regVudioEndEvent']),
  165. downFile(file) {
  166. uni.downloadFile({
  167. url: file,
  168. success: (data) => {
  169. if (data.statusCode === 200) {
  170. console.log('下载成功');
  171. uni.saveFile({
  172. tempFilePath: data.tempFilePath,
  173. success(res) {
  174. uni.showModal({
  175. title: '下载成功',
  176. content: '文件已保存:' + res.savedFilePath,
  177. success: (res_) => {
  178. }
  179. })
  180. }
  181. })
  182. }
  183. }
  184. })
  185. },
  186. palyVoice(item) {
  187. let _this = this
  188. _this.AUDIO.stop();
  189. _this.list_id = item.list_id;
  190. if (this.play_id == item.id) { //正在播放的是当前语音
  191. return _this.play_id = '';
  192. }
  193. let url = this.staticPath + _this.list_id + '/' + item.content.url;
  194. _this.AUDIO.src = url;
  195. _this.$nextTick(function() {
  196. _this.AUDIO.play();
  197. });
  198. return this.play_id = item.id
  199. },
  200. getDetail(val) {
  201. uni.navigateTo({
  202. url: 'store_info?type=' + val
  203. })
  204. },
  205. toDetail() {
  206. uni.navigateTo({
  207. url: 'store_detail'
  208. })
  209. },
  210. confrim(val) {
  211. console.log(val);
  212. let _this = this;
  213. if (val.type == 2) {
  214. uni.navigateTo({
  215. url: 'trans_index?id=' + this.id
  216. })
  217. } else {
  218. _get.deleteStore({
  219. id: this.id
  220. }, function(ret) {
  221. uni.showToast({
  222. title: ret.msg,
  223. icon: 'none',
  224. duration: '2000',
  225. });
  226. _this.$refs.popup.close()
  227. _this.list.splice(_this.selectIndex, 1);
  228. });
  229. }
  230. },
  231. openConfirm(item, index) {
  232. this.id = item.id;
  233. this.selectIndex = index;
  234. this.$refs.popup.open()
  235. },
  236. autoVideo(msg) {
  237. this.list_id = msg.list_id;
  238. this.showVedio = true;
  239. this.videoPath = _data.staticChat() + this.list_id + "/" + msg.content.url;
  240. },
  241. info(item) {
  242. if (item.type == 1) {
  243. return true;
  244. }
  245. if (item.type == 2) {
  246. let url = this.staticPath + item.list_id + '/' + item.content.url
  247. _page.imgPreview([url], 0);
  248. return true;
  249. }
  250. if (item.type == 3) {
  251. // _page.imgPreview([item.content.url],0);
  252. return true;
  253. }
  254. if (item.type == 4) { //视频
  255. this.autoVideo(item)
  256. return true;
  257. }
  258. //语音就播放
  259. //图片就预览
  260. //视频就播放
  261. // uni.navigateTo({
  262. // url:'store_item_info?id='+item.id
  263. // })
  264. }
  265. }
  266. }
  267. </script>
  268. <style lang="scss">
  269. .address-name {
  270. display: flex;
  271. flex-direction: column;
  272. }
  273. .address-flex {
  274. display: flex;
  275. align-items: center;
  276. }
  277. .fun-icon {
  278. width: 60rpx;
  279. height: 60rpx;
  280. margin: 10rpx;
  281. }
  282. .page {
  283. display: flex;
  284. flex-direction: column;
  285. }
  286. .page-header {
  287. display: flex;
  288. flex-direction: row;
  289. justify-content: space-between;
  290. padding: 50rpx 40rpx;
  291. }
  292. .page-header-left {
  293. display: flex;
  294. flex-direction: column;
  295. margin-left: 20px;
  296. }
  297. .page-header-right {
  298. display: flex;
  299. flex-direction: column;
  300. }
  301. .page-header-right-view1 {
  302. display: flex;
  303. flex: 1;
  304. }
  305. .page-header-right-view2 {
  306. display: flex;
  307. flex: 1;
  308. text-decoration: underline;
  309. color: #2c5f8a;
  310. }
  311. .page-content {
  312. display: flex;
  313. flex-direction: column;
  314. padding: 30rpx;
  315. }
  316. .page-content-header {
  317. display: flex;
  318. flex-direction: row;
  319. justify-content: space-around;
  320. }
  321. .page-content-list {
  322. display: flex;
  323. flex-direction: column;
  324. justify-content: space-between;
  325. }
  326. .page-content-item {
  327. display: flex;
  328. flex-direction: column;
  329. justify-content: space-between;
  330. padding: 8px;
  331. }
  332. .content-one {
  333. display: flex;
  334. justify-content: space-between;
  335. align-items: center;
  336. padding: 10px 0;
  337. }
  338. .content-two {
  339. display: flex;
  340. justify-content: space-between;
  341. align-items: center;
  342. }
  343. .page-header-info {
  344. display: flex;
  345. }
  346. .page-header-info image {
  347. width: 50px;
  348. height: 50px;
  349. }
  350. .voice {
  351. display: flex;
  352. justify-content: flex-start;
  353. align-items: center;
  354. background-color: #ffffff;
  355. width: 80px;
  356. padding: 2px 10px;
  357. border-radius: 10px;
  358. }
  359. .length {
  360. margin-left: 4rpx
  361. }
  362. .vedio {
  363. position: relative;
  364. }
  365. .content-one-image {
  366. width: 80px;
  367. height: 100px;
  368. }
  369. .bubble-bofang-left {
  370. position: absolute;
  371. left: 25px;
  372. top: 35px;
  373. width: 30px;
  374. height: 30px;
  375. }
  376. .text-info {
  377. padding: 10px 0;
  378. }
  379. .footer-hr {
  380. height: 1upx;
  381. width: 90%;
  382. background-color: #e1e1e1;
  383. margin: 0 auto;
  384. }
  385. @keyframes voicePlay {
  386. 0% {
  387. background-position: 0;
  388. }
  389. 100% {
  390. background-position: 100%;
  391. }
  392. }
  393. .voicePlay {
  394. animation-name: voicePlay;
  395. animation-duration: 10s;
  396. animation-direction: normal;
  397. animation-iteration-count: infinite;
  398. animation-timing-function: steps(3);
  399. }
  400. .play {
  401. @keyframes other-play {
  402. 0% {
  403. transform: translateX(-80%);
  404. }
  405. 100% {
  406. transform: translateX(0%);
  407. }
  408. }
  409. .icon-yuyin-you:after {
  410. border-right: solid 10upx rgba(255, 255, 255, .8);
  411. animation: other-play 1s linear infinite;
  412. left: 50upx;
  413. }
  414. }
  415. .icon-yuyin-you:after {
  416. content: " ";
  417. width: 40px;
  418. height: 40px;
  419. -webkit-border-radius: 100%;
  420. border-radius: 100%;
  421. position: absolute;
  422. -webkit-box-sizing: border-box;
  423. box-sizing: border-box;
  424. }
  425. .showVedio {
  426. width: 100%;
  427. height: 100%;
  428. position: absolute;
  429. left: 0;
  430. right: 0;
  431. top: 0;
  432. bottom: 0;
  433. z-index: 300;
  434. }
  435. .cloneBut {
  436. z-index: 400;
  437. position: relative;
  438. text-align: right;
  439. font-size: 24px;
  440. color: red;
  441. margin-left: 10px;
  442. margin-top: 10px;
  443. height: 30px;
  444. width: 30px;
  445. }
  446. .cloneBut-img {
  447. position: absolute;
  448. width: 30px;
  449. }
  450. </style>