index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. <template>
  2. <view class="">
  3. <!-- 扫一扫错误回调 -->
  4. <u-modal title="扫描异常" confirm-color="#dc9b21" v-model="scanNotify.scan" :content="scanNotify.scanMessage"></u-modal>
  5. <u-navbar :is-back="false" title="联兑通商户版"></u-navbar>
  6. <view class="margin-30">
  7. <view class="flex justify-between">
  8. <view class="title ">
  9. <view class="icon">
  10. <image src="@/static/icon/dianpu.png" mode=""></image>
  11. </view>
  12. <view class="center margin-left-10">
  13. <view @click="shopShow=true">
  14. <text class="name" >{{shopLable}}</text>
  15. <u-icon v-if="shopShow" name="arrow-up-fill" style="margin-left: 10rpx;"></u-icon>
  16. <u-icon v-else name="arrow-down-fill" style="margin-left: 10rpx;"></u-icon>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="btn">
  21. <view class="image">
  22. <image src="@/static/icon/logout.png" mode=""></image>
  23. </view>
  24. <view @click="logout" class="center padding-left-10" >
  25. <text>退出</text>
  26. <text class="cuIcon-right"></text>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="cu-list grid col-3 no-border top-menu">
  31. <view class="cu-item" @click="operate(index)" v-for="(item,index) in menuList" :key="index">
  32. <view class="grid-icon margin-top-20">
  33. <image style="width: 66rpx;height: 66rpx;" :src="item.icon" />
  34. </view>
  35. <text style="color: #fff;font-size: 26rpx;">{{item.name}}</text>
  36. </view>
  37. </view>
  38. <view class="menu-list">
  39. <view @click="$jump('/pages/bill/bill')" class="menu menu1">
  40. <view class="menu-top">
  41. <image src="@/static/icon/bill.png"></image>
  42. <view class="center padding-left-20">
  43. <text class="text-lg">我的账单</text>
  44. </view>
  45. </view>
  46. <view class="menu-bottom">
  47. <view class="">
  48. <text>今日营收</text>
  49. <text>{{statistic.todayIncome}}</text>
  50. </view>
  51. <view class="">
  52. <text>总资产</text>
  53. <text>{{statistic.totalAccount}}</text>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="menu menu2" @click="$jump('/pages/member/member')">
  58. <view class="menu-top">
  59. <image src="@/static/icon/center.png"></image>
  60. <view class="center padding-left-20">
  61. <text class="text-lg">会员中心</text>
  62. </view>
  63. </view>
  64. <view class="menu-bottom" style="color: #FFFFFF;">
  65. <view class="">
  66. <text>新增会员</text>
  67. <text>{{statistic.todayMemberIn}}</text>
  68. </view>
  69. <view class="">
  70. <text>会员总数</text>
  71. <text>{{statistic.memberCount}}</text>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. <view class="market">
  77. <text class="title">营销管理</text>
  78. <view class="cu-list grid col-2 no-border margin-top-30">
  79. <view class="cu-item" @click="$jump(item.path)" v-for="(item,index) in marketList" :key="index">
  80. <view class="grid-icon">
  81. <image mode="widthFix" style="width: 120rpx;" :src="item.icon" />
  82. </view>
  83. <text style="color: #222222;font-size: 26rpx;margin-top: 20rpx;">{{item.name}}</text>
  84. <view class="cu-tag bg-red badge" v-if="item.count>0">{{item.count}}</view>
  85. </view>
  86. </view>
  87. </view>
  88. <view class="system">
  89. <text class="title">数字化系统</text>
  90. <view class="cu-list grid col-4 no-border margin-top-30" style="border-radius:20rpx ;">
  91. <view class="cu-item" @click="$jump(item.path)" v-for="(item,index) in systemList" :key="index">
  92. <view class="grid-icon">
  93. <image mode="heightFix" style="height: 56rpx;" :src="item.icon" />
  94. </view>
  95. <text style="color: #222222;font-size: 26rpx;">{{item.name}}</text>
  96. <view class="cu-tag bg-red badge" v-if="item.count>0">{{item.count}}</view>
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. <!-- 支付键盘 -->
  102. <u-keyboard
  103. default=""
  104. ref="uKeyboard"
  105. mode="number"
  106. :mask="true"
  107. :mask-close-able="false"
  108. :dot-enabled="true"
  109. v-model="show"
  110. :confirm-btn="true"
  111. :safe-area-inset-bottom="true"
  112. :tooltip="false"
  113. @change="onChange"
  114. @backspace="onBackspace">
  115. <view>
  116. <view class="u-text-center u-padding-20 money">
  117. <view v-if="money=='0'" class="" style="position: absolute;left: 80rpx;bottom: 20rpx;">
  118. <text style="color: #909399;font-size: 24rpx;">请输入付款金额</text>
  119. </view>
  120. <text>{{money}}</text>
  121. <text class="u-font-20 u-padding-left-10">元</text>
  122. <view class="u-padding-10 close" data-flag="false" @tap="close">
  123. <u-icon name="close" color="#333333" size="28"></u-icon>
  124. </view>
  125. </view>
  126. <u-button @click="inputConfirm" plain :ripple="true" ripple-bg-color="rgba(25, 190, 107,.4)">确认</u-button>
  127. </view>
  128. </u-keyboard>
  129. <u-select @confirm="shopConfirm" v-model="shopShow" value-name="id" label-name="name" :list="shopList"></u-select>
  130. </view>
  131. </template>
  132. <script>
  133. export default {
  134. data() {
  135. return {
  136. show:false,
  137. money:"0",
  138. scanNotify:{scan: false,scanMessage:'扫描错误,请稍后重试!' },
  139. //下拉选择商铺
  140. shopShow:false,
  141. //我的商铺列表
  142. shopList:[],
  143. //选中的商铺id
  144. shopId:'',
  145. //选中的商铺labe
  146. shopLable:'',
  147. labelIds:'',
  148. labelNames:'',
  149. //选中的商铺所属的商场
  150. mallId:'',
  151. //统计数据
  152. statistic:{},
  153. menuList: [{
  154. icon: '/static/icon/scan.png',
  155. name: '扫一扫',
  156. },
  157. {
  158. icon: '/static/icon/pay.png',
  159. name: '收款码',
  160. },
  161. {
  162. icon: '/static/icon/card.png',
  163. name: '卡包',
  164. }
  165. ],
  166. marketList: [{
  167. icon: '/static/icon/faqi.png',
  168. name: '发起活动',
  169. background: "background-image:linear-gradient(#FF9549,#FCB07B)",
  170. path: '/pages/publish/publish',
  171. count: 0
  172. },
  173. {
  174. icon: '/static/icon/qingdan.png',
  175. name: '活动清单',
  176. background: "background-image:linear-gradient(#5892F7,#67BBF9)",
  177. path: '/pages/activity/activity',
  178. count: 0
  179. },
  180. ],
  181. systemList: [{
  182. icon: '/static/icon/system1.png',
  183. name: '外卖平台',
  184. path: '/pages/mine/card/card'
  185. },
  186. {
  187. icon: '/static/icon/system2.png',
  188. name: '预约系统',
  189. path: '/pages/mine/card/card'
  190. },
  191. {
  192. icon: '/static/icon/system3.png',
  193. name: 'ERP系统',
  194. path: '/pages/mine/card/card'
  195. },
  196. {
  197. icon: '/static/icon/system4.png',
  198. name: '线上商城',
  199. path: '/pages/mine/card/card'
  200. },
  201. {
  202. icon: '/static/icon/system5.png',
  203. name: '门店管理',
  204. path: '/pages/mine/card/card'
  205. },
  206. {
  207. icon: '/static/icon/add.png',
  208. name: '添加服务',
  209. path: '/pages/mine/card/card'
  210. },
  211. ]
  212. }
  213. },
  214. onLoad() {
  215. this.init()
  216. },
  217. onShow() {
  218. if (this.canReset) {
  219. this.getStatistic()
  220. }
  221. this.canReset=true
  222. },
  223. methods: {
  224. logout(){
  225. this.$dialog.showModal('确定要退出吗?').then(res=>{
  226. uni.clearStorage()
  227. uni.reLaunch({
  228. url:"../login/account-login"
  229. })
  230. })
  231. },
  232. async init(){
  233. let phone=this.$cache.get('phone')
  234. let params={
  235. personTel:phone,
  236. auditStatus:1 //审核通过
  237. }
  238. let res=await this.$api.shop.list(params)
  239. this.shopList=res.data.records
  240. let item=this.shopList[0]
  241. this.shopId = item.id
  242. this.shopLable = item.name
  243. this.labelIds = item.labelIds
  244. this.labelNames = item.labelNames
  245. this.mallId=item.mallId
  246. this.cacheSelectedShop(item)
  247. //获取统计数据
  248. this.getStatistic()
  249. },
  250. getStatistic(){
  251. this.$api.shop.statistic(this.shopId).then(res=>{
  252. this.statistic=res.data
  253. })
  254. },
  255. cacheSelectedShop(item){
  256. let selectedShop={
  257. id:this.shopId,
  258. label:this.shopLable,
  259. labelIds:this.labelIds,
  260. labelNames:this.labelNames
  261. }
  262. this.$cache.put("selectedShop",Object.assign(item,selectedShop))
  263. this.$u.vuex('vuex_shopId',this.shopId)
  264. this.$u.vuex('vuex_mallId',this.mallId)
  265. },
  266. shopConfirm(e){
  267. this.shopId=e[0].value
  268. this.shopLable=e[0].label
  269. let item = this.shopList.filter((item)=>{
  270. if(this.shopId==item.id){
  271. return true
  272. }
  273. })
  274. this.labelIds = item.labelIds
  275. this.labelNames = item.labelNames
  276. this.cacheSelectedShop(item)
  277. //获取统计数据
  278. this.getStatistic()
  279. },
  280. operate(index){
  281. if (index==0) {
  282. this.show=true
  283. }else if (index==1) {
  284. this.$jump('/pages/checkstand/pay-qrcode')
  285. }else if (index==2) {
  286. this.$jump('/pages/card/card')
  287. }
  288. },
  289. //扫描二维码
  290. onChange(val){
  291. if (this.money=='0' && val!='.') {
  292. this.money=val
  293. return
  294. }
  295. console.log(typeof this.money);
  296. console.log(typeof val);
  297. this.money += val.toString()
  298. },
  299. onBackspace(e){
  300. if(this.money.length>0 &&this.money!='0'){
  301. this.money = this.money.substring(0,this.money.length-1);
  302. }else{
  303. this.money='0'
  304. }
  305. },
  306. inputConfirm(){
  307. if (this.$isEmpty(this.money)) {
  308. this.$u.toast('请输入收款金额')
  309. return
  310. }
  311. if (!this.$verify.isMoney(this.money)) {
  312. this.$u.toast('请输入正确的收款金额')
  313. return
  314. }
  315. this.show=false
  316. this.scanCode()
  317. },
  318. close(){
  319. this.money='0'
  320. this.show=false
  321. },
  322. scanCode(){
  323. const _this = this;
  324. uni.scanCode({
  325. success: function (res) {
  326. _this.payBefore(res.result)
  327. },
  328. fail: (res) => {
  329. if(res.errMsg!='scanCode:fail cancel'){
  330. _this.scanNotify = {scan: true,scanMessage: res.errMsg};
  331. }
  332. }
  333. });
  334. },
  335. async payBefore(secret){
  336. let expireTime=this.$dateTime.getExpireTime(5)
  337. let params={
  338. shopId:this.vuex_shopId,
  339. money:this.money,
  340. billsTitle:'用户支付',
  341. expireTime,
  342. appId:this.$global.wxParams.clientAppId,
  343. secret,
  344. type:2
  345. }
  346. let resp=await this.$api.shop.payBefore(params)
  347. console.log(resp);
  348. }
  349. }
  350. }
  351. </script>
  352. <style lang="scss" scoped>
  353. .cu-list.grid>.cu-item .cu-tag {
  354. right: auto;
  355. left: 54%;
  356. margin-left: 20rpx;
  357. }
  358. .title {
  359. display: flex;
  360. .icon {
  361. background-color: #FFFFFF;
  362. border-radius: 50%;
  363. display: flex;
  364. justify-content: center;
  365. align-items: center;
  366. width: 50rpx;
  367. height: 50rpx;
  368. image {
  369. width: 36rpx;
  370. height: 36rpx;
  371. }
  372. }
  373. text {
  374. font-weight: 800;
  375. font-size: 32rpx;
  376. color: #303030;
  377. }
  378. }
  379. .top-menu {
  380. border-radius: 20rpx;
  381. margin-top: 20rpx;
  382. background-image: linear-gradient(to right, #FBA33D, #FF8D32);
  383. }
  384. .menu-list {
  385. display: flex;
  386. justify-content: space-between;
  387. padding-top: 20rpx;
  388. .menu {
  389. width: 48.8%;
  390. color: #FFFFFF;
  391. display: flex;
  392. flex-direction: column;
  393. align-items: center;
  394. border-radius: 14rpx;
  395. padding: 30rpx 20rpx;
  396. .menu-top {
  397. display: flex;
  398. image {
  399. width: 70rpx;
  400. height: 70rpx;
  401. }
  402. }
  403. .menu-bottom {
  404. padding-top: 20rpx;
  405. font-size: 30rpx;
  406. display: flex;
  407. justify-content: space-around;
  408. width: 100%;
  409. view {
  410. display: flex;
  411. flex-direction: column;
  412. text-align: center;
  413. text:first-child {
  414. margin-bottom: 10rpx;
  415. font-size: 26rpx;
  416. color: #E0E2F6;
  417. }
  418. }
  419. }
  420. }
  421. .menu1 {
  422. background-color: #5C6186;
  423. }
  424. .menu2 {
  425. background-color: #E19D5B;
  426. }
  427. }
  428. .market {
  429. margin-top: 20rpx;
  430. border-radius: 20rpx;
  431. background-color: #FFFFFF;
  432. padding: 30rpx 50rpx 20rpx;
  433. .title {
  434. font-weight: 800;
  435. }
  436. }
  437. .system {
  438. margin-top: 20rpx;
  439. border-radius: 20rpx;
  440. background-color: #FFFFFF;
  441. padding: 30rpx 50rpx 20rpx;
  442. .title {
  443. font-weight: 800;
  444. }
  445. }
  446. .btn{
  447. margin-right: -30rpx;
  448. display: flex;
  449. .image{
  450. display: flex;
  451. justify-content: center;
  452. align-items: center;
  453. border-radius: 50%;
  454. background-color: #FFFFFF;
  455. padding: 8rpx;
  456. image{
  457. width: 20rpx;
  458. height: 20rpx;
  459. }
  460. }
  461. color: #FFFFFF;
  462. border-radius: 50rpx 0 0 50rpx;
  463. padding:8rpx 10rpx 8rpx 35rpx;
  464. background-image: linear-gradient(to right,#FFD67B,#F99200);
  465. }
  466. .money{
  467. font-size: 80rpx;
  468. color: $u-type-warning;
  469. position: relative;
  470. .close{
  471. position: absolute;
  472. top: 20rpx;
  473. right: 20rpx;
  474. line-height: 28rpx;
  475. font-size: 28rpx;
  476. }
  477. }
  478. </style>