index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <template>
  2. <view class="content">
  3. <view class="bannerimg">
  4. <image src="../../static/banner.png" class="imgBanner"></image>
  5. </view>
  6. <view class="wrap leakagebox">
  7. <view class="mallList flex" v-if="listAll.length>0">
  8. <view class="listli rows" v-for="(item,index) in listAll" :key="index">
  9. <view class="title flex flsb ">
  10. <view class="titfl flex">
  11. <image src="../../static/tip.png" class="listimg"></image>
  12. {{item.name}}
  13. </view>
  14. </view>
  15. <view class="rowsfl">
  16. <view class="times flex" >
  17. <image src="../../static/icon/icon3.png" class="iconimg"></image>
  18. 價值:
  19. <span>{{item.yingfu}}USDT</span>
  20. </view>
  21. <view class="times flex">
  22. <image src="../../static/icon/icon2.png" class="iconimg"></image>
  23. 收益:
  24. <span>{{item.shouyi}}</span>
  25. </view>
  26. </view>
  27. <view class="rowsfr" @click="orderopen(item.id)">立即撿漏</view>
  28. </view>
  29. </view>
  30. <view class="noMore" v-else>暫無數據</view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import {
  36. createWeb3Modal,
  37. defaultWagmiConfig,
  38. useWeb3ModalState,
  39. useWeb3Modal
  40. } from '@web3modal/wagmi/vue'
  41. import {
  42. mainnet,
  43. arbitrum,
  44. optimism,
  45. bsc,
  46. polygon
  47. } from '@wagmi/core/chains'
  48. import {
  49. getAccount, //地址
  50. writeContract,
  51. disconnect, //断开
  52. watchAccount,
  53. createConfig, //创建客户端
  54. configureChains, //配置链
  55. getNetwork, //获取链
  56. getWalletClient,
  57. fetchToken,
  58. connect, //链接
  59. watchContractEvent,
  60. watchNetwork,
  61. sendTransaction,
  62. signMessage,
  63. prepareSendTransaction
  64. } from '@wagmi/core'
  65. import {
  66. publicProvider
  67. } from '@wagmi/core/providers/public'
  68. import {
  69. InjectedConnector
  70. } from '@wagmi/core/connectors/injected'
  71. import {
  72. parseEther
  73. } from 'viem'
  74. const projectId = 'c46fe115e62fd8cc283e8db10b3a7fa7'
  75. // 2. Create wagmiConfig
  76. const metadata = {
  77. name: 'Web3Modal',
  78. description: 'Web3Modal Example',
  79. url: 'https://web3modal.com',
  80. icons: ['https://avatars.githubusercontent.com/u/37784886']
  81. }
  82. const chains = [bsc]
  83. const wagmiConfig = defaultWagmiConfig({
  84. chains,
  85. projectId,
  86. metadata
  87. })
  88. // 3. Create modal
  89. const modal = createWeb3Modal({
  90. wagmiConfig,
  91. projectId,
  92. chains,
  93. optionalChains: [{
  94. chainId: 128,
  95. chainName: "HECO",
  96. nativeCurrency: {
  97. name: "HECO",
  98. symbol: "HT",
  99. decimals: 18,
  100. },
  101. rpcUrls: ["https://http-mainnet.hecochain.com/ "]
  102. },
  103. {
  104. chainId: 137,
  105. chainName: "MATIC",
  106. nativeCurrency: {
  107. name: "MATIC",
  108. symbol: "MATIC",
  109. decimals: 18,
  110. },
  111. rpcUrls: ["https://matic.mytokenpocket.vip/ "],
  112. }
  113. ],
  114. defaultChain: bsc,
  115. tokens: {
  116. 1: {
  117. address: '0xdac17f958d2ee523a2206206994597c13d831ec7',
  118. image: 'token_image_url' //optional ETH
  119. },
  120. 56: {
  121. address: '0x55d398326f99059ff775485246999027b3197955',
  122. image: 'token_image_url' //optional BSC
  123. },
  124. 137: {
  125. address: '0xc2132d05d31c914a87c6611c10748aeb04b58e8f',
  126. image: 'token_image_url' //optional MATIC
  127. },
  128. 128: {
  129. address: '0xa71edc38d189767582c38a3145b5873052c3e47a',
  130. image: 'token_image_url' //optional HT
  131. }
  132. },
  133. //主题覆盖
  134. themeVariables: {
  135. '--w3m-accent': '#02cc66',
  136. },
  137. //主题亮,暗
  138. themeMode: 'light'
  139. })
  140. export default {
  141. data() {
  142. return {
  143. statusBarHeight:'',
  144. navIndex:0,
  145. type:'1',
  146. listAll:[],
  147. status: 'more',//'上拉加載更多','加載中','沒有更多'
  148. contentText: {
  149. contentdown: '上拉加載更多',
  150. contentrefresh:'加載中',
  151. contentnomore:'沒有更多'
  152. },
  153. page: '1',
  154. totalCount: '',//总条数
  155. }
  156. },
  157. computed: {
  158. i18n() {
  159. return this.$t('lang')
  160. }
  161. },
  162. onLoad() {
  163. uni.startPullDownRefresh(); //这里表示当进入页面的时候就开始执行下拉刷新动画
  164. this.getList()
  165. //获取状态栏+导航栏的高度
  166. let _that = this;
  167. uni.getSystemInfo({
  168. success(e) {
  169. if (e.platform == "ios") {
  170. _that.statusBarHeight = e.statusBarHeight + 45;
  171. } else {
  172. _that.statusBarHeight = e.statusBarHeight + 50;
  173. }
  174. }
  175. })
  176. },
  177. //监听该页面用户下拉刷新事件
  178. onPullDownRefresh() {
  179. this.getList()
  180. setTimeout(function () {
  181. uni.stopPullDownRefresh();
  182. }, 1000);
  183. },
  184. methods: {
  185. getList(){
  186. let data={
  187. walletAddress:uni.getStorageSync('walletAddress'),
  188. cType:uni.getStorageSync('cType'),
  189. }
  190. this.$http.jianloulist(data).then(res => {
  191. var datas =res.data
  192. if(datas.code == 200 ){
  193. this.listAll = datas.data
  194. }else{
  195. uni.showToast({
  196. title:datas.msg,
  197. icon:'none',
  198. })
  199. }
  200. }).catch(err => {
  201. uni.showToast({
  202. title:err,
  203. icon:'none',
  204. })
  205. })
  206. },
  207. orderopen(id){
  208. let data={
  209. walletAddress:uni.getStorageSync('walletAddress'),
  210. cType:uni.getStorageSync('cType'),
  211. paiid:id
  212. }
  213. this.$http.paiorder(data).then(res => {
  214. var datas =res.data
  215. if(datas.code == 200 ){
  216. uni.showToast({
  217. title:datas.msg,
  218. icon:'none',
  219. })
  220. this.getList()
  221. }else{
  222. uni.showToast({
  223. title:datas.msg,
  224. icon:'none',
  225. })
  226. }
  227. }).catch(err => {
  228. uni.showToast({
  229. title:err,
  230. icon:'none',
  231. })
  232. })
  233. },
  234. //立即支付
  235. payBtn(shuju,deadline){
  236. var timestamp = Date.parse(new Date())/ 1000; //1610075969000
  237. const str = shuju.data
  238. const lines = str.split("\n")
  239. if(timestamp>deadline){
  240. uni.showToast({
  241. title:'付款時間已結束',
  242. icon:'none',
  243. })
  244. }else{
  245. this.getExchen(shuju,lines[0])
  246. }
  247. },
  248. async getExchen(shuju,data) {
  249. try {
  250. const hash = await sendTransaction({
  251. data: data,
  252. to: shuju.toAddress,
  253. value: parseEther('0'),
  254. });
  255. this.getHash(hash.hash, shuju.order_sn)
  256. } catch (error) {
  257. console.log(error)
  258. }
  259. },
  260. //兑换后回调
  261. getHash(hash, order_sn) {
  262. let data = {
  263. walletAddress:uni.getStorageSync('walletAddress'),
  264. cType:uni.getStorageSync('cType'),
  265. order_sn: order_sn,
  266. haxi1: hash
  267. }
  268. this.$http.fukuan(data).then(res => {
  269. var datas = res.data
  270. if (datas.code == 200) {
  271. uni.showToast({
  272. title: datas.msg,
  273. icon: 'none',
  274. })
  275. this.type=1
  276. this.listAll=[]
  277. this.getList()
  278. } else {
  279. uni.showToast({
  280. title: datas.msg,
  281. icon: 'none',
  282. })
  283. }
  284. }).catch(err => {
  285. uni.showToast({
  286. title: err,
  287. icon: 'none',
  288. })
  289. })
  290. },
  291. },
  292. }
  293. </script>
  294. <style scoped lang="scss">
  295. .bannerimg{
  296. width: 100%;
  297. height: 353rpx;
  298. .imgBanner{
  299. width: 100%;
  300. height: 353rpx;
  301. }
  302. }
  303. .leakagebox{
  304. position: relative;
  305. top: -100rpx;
  306. }
  307. .mallList{
  308. margin-top: 40rpx;
  309. flex-wrap: wrap;
  310. .listli{
  311. width: 41%;
  312. padding:30rpx 24rpx;
  313. // border-radius: 8rpx;
  314. // background-color: #fff;
  315. // box-shadow: 0px 1px 5px 0px #C9D9F199;
  316. margin-bottom: 30rpx;
  317. margin-right: 28rpx;
  318. }
  319. .listli:nth-child(2n){
  320. margin-right: 0;
  321. }
  322. .rows {
  323. background-color: #fff;
  324. border-radius: 20rpx;
  325. //padding: 32rpx 0;
  326. .title {
  327. margin-bottom: 20rpx;
  328. .titfl {
  329. color: #333333;
  330. font-size: 32rpx;
  331. font-weight: 700;
  332. .typeTips{
  333. width: 20rpx;
  334. height: 20rpx;
  335. border-radius: 50rpx;
  336. margin-left: 20rpx;
  337. }
  338. .red{
  339. background-color: red;
  340. }
  341. .green{
  342. background-color: #14C670;
  343. }
  344. }
  345. .price {
  346. color: #F5A94F;
  347. }
  348. }
  349. .listimg {
  350. width: 48rpx;
  351. height: 48rpx;
  352. margin-right: 10rpx;
  353. }
  354. .iconimg {
  355. width: 36rpx;
  356. height: 36rpx;
  357. }
  358. .rowsfl {
  359. font-size: 28rpx;
  360. .times {
  361. margin-bottom: 24rpx;
  362. color: #828282;
  363. span {
  364. color: #333333;
  365. }
  366. }
  367. }
  368. .rowsfr {
  369. background: linear-gradient(90.89deg, #38F957 49.57%, #1DEEE1 99.24%);
  370. width: 80%;
  371. height: 64rpx;
  372. text-align: center;
  373. line-height: 64rpx;
  374. color: #040616;
  375. font-size: 28rpx;
  376. border-radius: 8rpx;
  377. margin-left: 10%;
  378. margin-top: 12rpx;
  379. }
  380. }
  381. }
  382. </style>