box.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <view class="page">
  3. <uni-nav-bar rightWidth='136rpx' title="燃料中心" fixed :border="false" statusBar backgroundColor="#24234B" color="#FFFFFF">
  4. <template #left>
  5. <view class="cl-topbar__icon" @click="navigateBack">
  6. <text class="cl-icon-arrow-left"></text>
  7. </view>
  8. </template>
  9. <template #right>
  10. <view style="
  11. width: 136rpx;
  12. height: 52rpx;
  13. background: linear-gradient( 130deg, #322D52 20%, #6E47A2 100%);
  14. border-radius: 12rpx;
  15. text-align: center;
  16. line-height:52rpx;
  17. color: #FFFFFF;
  18. font-weight: bold;
  19. font-size: 24rpx;
  20. " @click="navToTranRecord">
  21. 记录
  22. </view>
  23. </template>
  24. </uni-nav-bar>
  25. <view class="tabMain">
  26. <view class="menu" :class="tab==1?'active':''" @click="selTab(1)">
  27. 日常探索
  28. </view>
  29. <view class="menu" :class="tab==2?'active2':''" @click="selTab(2)">
  30. 探索奖励
  31. </view>
  32. </view>
  33. <view class="tabMain2" v-if="tab == 1">
  34. <view class="menu" :class="tab2==1?'active':''" @click="selTab2(1)">
  35. 开拓者燃料
  36. </view>
  37. <view class="menu" :class="tab2==2?'active':''" @click="selTab2(2)">
  38. 进行中
  39. </view>
  40. <view class="menu" :class="tab2==3?'active':''" @click="selTab2(3)">
  41. 已完成
  42. </view>
  43. </view>
  44. <view class="thread"></view>
  45. <view class="list_item state12" v-if="false">
  46. <view class="item1">
  47. <text class="left">星际通行证</text>
  48. <text class="right">已拓中1/1</text>
  49. </view>
  50. <view class="item2">
  51. <view class="left">
  52. <image class="icon" mode="widthFix" src="http://c.yujianmate.com/images/v1/w3/icon_item.png">
  53. </image>
  54. <text class="name">待解锁:1/5天</text>
  55. <text class="time">开拓日期:2024.9.1</text>
  56. </view>
  57. <view class="right">
  58. <view class="content">探索需要50个暗物质,可探索获得80个暗物质,周期30 天,最多可完成1次探索。</view>
  59. <view class="act">
  60. <text class="state_name">待领取:12</text>
  61. <image class="icon" mode="heightFix" src="https://c.yujianmate.com/images/v1/w3/x_get.png">
  62. </image>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. <view v-if="nodata" class="empty">
  68. <view class="bg"></view>
  69. <text style="margin-top: 0rpx;font-size: 24rpx;color: #999999;">暂无数据</text>
  70. </view>
  71. <view class="list_item" v-for="(item,index) in list" :class="tab2 > 1?'state12':''">
  72. <view class="item2">
  73. <view class="left">
  74. <image class="icon" mode="widthFix"
  75. :src="'http://c.yujianmate.com/images/v1/w3/box/box_'+item.id+'.png'"></image>
  76. <view class="price">
  77. {{item.num_dui}}暗物质
  78. </view>
  79. <block v-if="item.num_have > 0">
  80. <text class="name">待解锁:{{item.num_sign}}/{{item.num_task}}天</text>
  81. <text class="time">开拓日期:{{item.tdate}}</text>
  82. </block>
  83. </view>
  84. <view class="right">
  85. <view class="item1">
  86. <text class="left2">{{item.name}}</text>
  87. <text class="right2">开拓中{{item.num_have}}/{{item.num}}</text>
  88. </view>
  89. <view class="content">
  90. 探索需要{{item.num_dui}}个暗物质,可探索获得{{item.num_jkb}}个暗物质,周期{{item.num_limit_day}}
  91. 天,最多可完成{{item.num}}次探索。
  92. </view>
  93. <view class="act">
  94. <block v-if="tab2 == 1 && item.num_have < item.num && tab == 1">
  95. <view class="btn" @click="onDuihuan(item)">
  96. 探索
  97. </view>
  98. </block>
  99. <block v-if="tab2 == 2">
  100. <text class="sign_name"></text>
  101. </block>
  102. <block v-if="tab2 == 2 && tab == 1">
  103. <text class="state_name">待领取:{{item.can_get_gmb}}</text>
  104. <!-- <image class="icon" mode="heightFix" src="http://c.yujianmate.com/images/v1/w3/x_get.png"></image> -->
  105. </block>
  106. <block v-if="tab == 2">
  107. <view class="btn" @click="onJihuo(item)">
  108. 探索
  109. </view>
  110. </block>
  111. </view>
  112. </view>
  113. </view>
  114. </view>
  115. <view class="thread2"></view>
  116. <DialogBoxW3 ref="DialogBoxW3"></DialogBoxW3>
  117. <ToastW3 ref="ToastW3"></ToastW3>
  118. </view>
  119. </template>
  120. <script>
  121. import uniNavBar from '../../components/uni-ui/uni-nav-bar/uni-nav-bar.vue'
  122. export default {
  123. components: {
  124. uniNavBar
  125. },
  126. data() {
  127. return {
  128. title: '',
  129. tab: 1,
  130. tab2: 1,
  131. list: [],
  132. nodata: true,
  133. }
  134. },
  135. onLoad() {
  136. let self = this;
  137. // try {
  138. // var uniIcon = document.getElementsByClassName('uni-page-head-btn')[0]
  139. // uniIcon.style.display = 'block';
  140. // } catch (e) {
  141. // //TODO handle the exception
  142. // }
  143. this.loadBoxList(1, this.tab);
  144. },
  145. onShow() {
  146. // uni.hideTabBar({
  147. // animation:false
  148. // })
  149. // this.loadData(1);
  150. // this.showBottomPlayer();
  151. },
  152. methods: {
  153. navigateBack(){
  154. uni.navigateBack(1)
  155. },
  156. navToTranRecord() {
  157. uni.navigateTo({
  158. url: "/pages/w3/tranRecord?stype=ad",
  159. })
  160. },
  161. selTab(tb) {
  162. this.tab = tb;
  163. this.loadBoxList(this.tab2, this.tab);
  164. },
  165. selTab2(tb) {
  166. this.tab2 = tb;
  167. this.loadBoxList(this.tab2, this.tab);
  168. },
  169. onDuihuan(item) {
  170. let that = this;
  171. this.$refs['DialogBoxW3'].confirm({
  172. title: '探索',
  173. content: '是否消耗' + item.num_dui + '个暗物质开启通行证',
  174. DialogType: 'inquiry',
  175. btn1: '',
  176. btn2: '',
  177. animation: 0
  178. }).then((res) => {
  179. uni.request({
  180. url: this.$apiHost + "/Box/duihuan",
  181. data: {
  182. uuid: getApp().globalData.uuid,
  183. id: item.id
  184. },
  185. header: {
  186. "content-type": "application/json",
  187. 'sign': getApp().globalData.headerSign
  188. },
  189. success: (res) => {
  190. console.log("----", res.data.list);
  191. // uni.showToast({
  192. // title: res.data.str,
  193. // icon: 'none'
  194. // })
  195. that.$refs['ToastW3'].showToast({
  196. title: res.data.str,
  197. animation: 0
  198. });
  199. if (res.data.success == "yes") {
  200. that.loadBoxList(1, this.tab);
  201. }
  202. },
  203. complete: (com) => {
  204. uni.hideLoading();
  205. },
  206. });
  207. // getApp().globalData.skey = "";
  208. // uni.removeStorageSync("wapptoken")
  209. // uni.redirectTo({
  210. // url: '/pages/index/login',
  211. // })
  212. // uni.navigateBack();
  213. // uni.sendNativeEvent("logout","tt", function(e){
  214. // //关闭当前小程序
  215. // console.log("sendNativeEvent-----------回调"+JSON.stringify(e));
  216. // });
  217. })
  218. },
  219. onJihuo(item) {
  220. let that = this;
  221. uni.request({
  222. url: this.$apiHost + "/Box/jihuo",
  223. data: {
  224. uuid: getApp().globalData.uuid,
  225. id: item.item_id
  226. },
  227. header: {
  228. "content-type": "application/json",
  229. 'sign': getApp().globalData.headerSign
  230. },
  231. success: (res) => {
  232. console.log("----", res.data.list);
  233. that.$refs['ToastW3'].showToast({
  234. title: res.data.str,
  235. animation: 0
  236. });
  237. if (res.data.success == "yes") {
  238. that.loadBoxList(2, this.tab);
  239. }
  240. },
  241. complete: (com) => {
  242. uni.hideLoading();
  243. },
  244. });
  245. },
  246. loadBoxList(tab, type) {
  247. let that = this;
  248. uni.request({
  249. url: this.$apiHost + "/Box/getlist", //仅为示例,并非真实接口地址。
  250. data: {
  251. uuid: getApp().globalData.uuid,
  252. tab: tab,
  253. type: type,
  254. },
  255. header: {
  256. "content-type": "application/json",
  257. 'sign': getApp().globalData.headerSign
  258. },
  259. success: (res) => {
  260. console.log("----", res.data.list);
  261. if (res.data.success == "yes") {
  262. that.list = res.data.list || [];
  263. that.nodata = !(that.list.length > 0)
  264. }
  265. },
  266. complete: (com) => {
  267. uni.hideLoading();
  268. },
  269. });
  270. },
  271. }
  272. }
  273. </script>
  274. <style scoped lang="scss">
  275. @import 'box.scss';
  276. </style>