store_info.vue 9.8 KB

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