酷炫直播运营系统小程序版本

livingdata.vue 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <view>
  3. <view class="unit_pad flex-between livingtotal">
  4. <text class="fWeight600 f40">直播间成交额</text>
  5. <view class="flex" style="justify-content: flex-end;align-items: flex-end;">
  6. <text class="c-F39F2F" style="font-size:36rpx;line-height: 62rpx;margin-right: 10rpx;">¥</text>
  7. <text class="c-F39F2F f60">{{scorePreview&&scorePreview.total_money || scorePreview&&scorePreview.total_money == 0 ? $formatNum(scorePreview.total_money) : '-'}}</text>
  8. </view>
  9. </view>
  10. <!--自定义指标-->
  11. <view class="flexWrap livingBox" style="padding: 20rpx 10rpx">
  12. <view v-for="l in livingData_all" v-if="l.checked == 1" :key="l.key" class="livingItem">
  13. <view>
  14. <image :src="l.other.icon" alt="" mode="heightFix"></image>
  15. </view>
  16. <view class="f26">{{l.name}}</view>
  17. <view>
  18. <text class="f28 fWeight600">{{l.value || l.value == 0 ? $formatNum(l.value) : '-'}}</text>
  19. <text class="f20 lMar8">{{l.other.unit}}</text>
  20. </view>
  21. </view>
  22. <view class="livingItem" @click="showDrawer">
  23. <view class="f50">+</view>
  24. <view class="f28">自定义</view>
  25. </view>
  26. </view>
  27. <!--正在直播-->
  28. <view v-if="livingList&&livingList.length>0" class="livingListBox">
  29. <view class="splitLine"></view>
  30. <view class="unit_pad flex-between">
  31. <view>
  32. <text class="livingTxt">正在直播</text>
  33. <image src="../../static/live.gif" alt="" mode="widthFix" style="width: 30rpx;margin-left: 10rpx"></image>
  34. </view>
  35. <view class="flex" style="justify-content: flex-end;flex:1;">
  36. <template v-for="(l,index) in livingList">
  37. <view v-if="index<6" :key="l.user_id">
  38. <image :src="l.cover_img" alt="" class="livingImg"></image>
  39. </view>
  40. </template>
  41. </view>
  42. </view>
  43. </view>
  44. <uni-drawer ref="showlivingMask" mode="left">
  45. <scroll-view style="height: 100%;width: 550rpx" scroll-y="true" class="drawerBox">
  46. <view class="f32 c-BCBCBC" style="padding: 120rpx 40rpx 20rpx">编辑</view>
  47. <view v-for="(l,idx) in livingData_all" :key="l.key" class="drawer_item" :class="idx == livingData_all.length-1 ? '' : 'drawer_item_border'">
  48. <view class="f28">{{ l.name }}</view>
  49. <view class="f42" @click="save_Data(l)">
  50. <text class="minus" v-if="l.checked == 1">-</text>
  51. <text v-else>+</text>
  52. </view>
  53. </view>
  54. </scroll-view>
  55. </uni-drawer>
  56. </view>
  57. </template>
  58. <script>
  59. export default {
  60. data(){
  61. return{
  62. livingList: [],
  63. scorePreview: {},
  64. livingData_all: [],//所有自定义数据
  65. old_livingData_all:[],
  66. have_livdata_len: 0,//当前所选指标的个数
  67. }
  68. },
  69. methods:{
  70. showDrawer () {
  71. this.$refs.showlivingMask.open();
  72. },
  73. init_uType_non3(){
  74. // this.get_living_Data()//获取自定义所有数据
  75. // this.get_livingList()//正在直播
  76. // this.get_scorePreview()//直播数据
  77. let pro1 = new Promise((resolve, reject)=>{
  78. this.get_living_Data(()=>{
  79. resolve()
  80. })
  81. })
  82. let pro2 = new Promise((resolve, reject)=>{
  83. this.get_livingList(()=>{
  84. resolve()
  85. })
  86. })
  87. // let pro3 = new Promise((resolve, reject)=>{
  88. // this.get_scorePreview(()=>{
  89. // resolve()
  90. // })
  91. // })
  92. Promise.all([pro1,pro2]).then(()=>{
  93. this.$hide_init_loading()
  94. uni.stopPullDownRefresh()
  95. this.$emit('livingTimerEdit',
  96. setTimeout(()=>{
  97. this.init_uType_non3()
  98. },10*1000)
  99. )
  100. })
  101. },
  102. get_living_Data (cb) {
  103. this.$req(this.$api.search_config_all, 'get', {
  104. type: 'XCX_INDEX_DATA_PREVIEW',
  105. method: 'user'
  106. }, (res) => {
  107. if (res && res.errno == 0) {
  108. this.old_livingData_all = res.rst.seting[0].list
  109. this.old_livingData_all.forEach(l => {
  110. if (l.checked == 1) {
  111. this.have_livdata_len += 1
  112. }
  113. })
  114. this.get_scorePreview(cb)
  115. }else{
  116. cb ? cb() : ''
  117. }
  118. }, (err)=>{
  119. cb ? cb() : ''
  120. })
  121. },
  122. get_livingList (cb) {
  123. this.$req(this.$api.market_livingList, 'get', {}, (res) => {
  124. cb ? cb() : ''
  125. if (res && res.errno == 0) {
  126. this.livingList = res.rst.list;
  127. }
  128. },(err)=>{
  129. cb ? cb() : ''
  130. })
  131. },
  132. get_scorePreview (cb) {
  133. this.$req(this.$api.market_scorePreview, 'get', {}, (res) => {
  134. cb ? cb() : ''
  135. if (res && res.errno == 0) {
  136. this.scorePreview = res.rst
  137. if (!res.rst) { return false }
  138. this.old_livingData_all.forEach(l => {
  139. l.value = res.rst[l.key]
  140. })
  141. this.livingData_all = this.old_livingData_all
  142. }
  143. },(err)=>{
  144. cb ? cb() : ''
  145. })
  146. },
  147. save_Data (l) { //保存还显示的数据项
  148. if (l.checked == 1) {
  149. if (this.have_livdata_len <= 4) {
  150. uni.showToast({
  151. title: '最少选择4项',
  152. icon: 'none',
  153. duration: 2000
  154. })
  155. return false
  156. }
  157. l.checked = 0
  158. this.have_livdata_len -= 1
  159. } else {
  160. l.checked = 1
  161. this.have_livdata_len += 1
  162. }
  163. let lastcolumn = []
  164. this.livingData_all.forEach(l => {
  165. if (l.checked == 1) {
  166. lastcolumn.push(l.key)
  167. }
  168. })
  169. this.$req(this.$api.save_checked_status, 'post', {
  170. type: 'XCX_INDEX_DATA_PREVIEW',
  171. column: lastcolumn
  172. })
  173. },
  174. }
  175. }
  176. </script>
  177. <style scoped lang="scss">
  178. .unit_pad {
  179. padding: 20rpx 32rpx;
  180. }
  181. .livingListBox{
  182. background-color: #373E4E;
  183. .livingImg {
  184. width: 76rpx;
  185. height: 76rpx;
  186. border: 1px solid #f5225c;
  187. margin-left: 6rpx;
  188. border-radius: 50%;
  189. }
  190. .splitLine {
  191. height: 16rpx;
  192. background-color: #262C38;
  193. }
  194. }
  195. .livingtotal {
  196. background: #1B1E25;
  197. border-bottom: 2px solid #303643;
  198. }
  199. .livingBox {
  200. background: #1B1E25;
  201. .livingItem {
  202. width: 25%;
  203. text-align: center;
  204. margin-bottom: 30rpx;
  205. margin-top: 20rpx;
  206. image {
  207. width: 40rpx;
  208. height: 40rpx;
  209. }
  210. }
  211. .livingTxt {
  212. font-size: 32rpx;
  213. font-weight: 600;
  214. }
  215. }
  216. .drawerBox {
  217. background-color: #2a2c3b;
  218. .drawer_item {
  219. display: flex;
  220. align-items: center;
  221. justify-content: space-between;
  222. padding: 32rpx 60rpx 26rpx 40rpx;
  223. .minus {
  224. background-color: red;
  225. border-radius: 50%;
  226. width: 40rpx;
  227. height: 40rpx;
  228. line-height: 32rpx;
  229. text-align: center;
  230. display: inline-block;
  231. }
  232. }
  233. .drawer_item_border {
  234. border-bottom: 1px solid #585c69;
  235. }
  236. }
  237. </style>