index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  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">
  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="center">
  81. <view class="icon" :style="item.background">
  82. <image :src="item.icon" mode=""></image>
  83. </view>
  84. </view>
  85. <text style="color: #222222;font-size: 26rpx;margin-top: 20rpx;">{{item.name}}</text>
  86. <view class="cu-tag bg-red badge" v-if="item.count>0">{{item.count}}</view>
  87. </view>
  88. </view>
  89. </view>
  90. <view class="system">
  91. <text class="title">数字化系统</text>
  92. <view class="cu-list grid col-4 no-border margin-top-30" style="border-radius:20rpx ;">
  93. <view class="cu-item" @click="$jump(item.path)" v-for="(item,index) in systemList" :key="index">
  94. <view class="grid-icon">
  95. <image mode="heightFix" style="height: 56rpx;" :src="item.icon" />
  96. </view>
  97. <text style="color: #222222;font-size: 26rpx;">{{item.name}}</text>
  98. <view class="cu-tag bg-red badge" v-if="item.count>0">{{item.count}}</view>
  99. </view>
  100. </view>
  101. </view>
  102. </view>
  103. <!-- 支付键盘 -->
  104. <u-keyboard
  105. default=""
  106. ref="uKeyboard"
  107. mode="number"
  108. :mask="true"
  109. :mask-close-able="false"
  110. :dot-enabled="true"
  111. v-model="show"
  112. :confirm-btn="true"
  113. :safe-area-inset-bottom="true"
  114. :tooltip="false"
  115. @change="onChange"
  116. @backspace="onBackspace">
  117. <view>
  118. <view class="u-text-center u-padding-20 money">
  119. <view v-if="money=='0'" class="" style="position: absolute;left: 80rpx;bottom: 20rpx;">
  120. <text style="color: #909399;font-size: 24rpx;">请输入付款金额</text>
  121. </view>
  122. <text>{{money}}</text>
  123. <text class="u-font-20 u-padding-left-10">元</text>
  124. <view class="u-padding-10 close" data-flag="false" @tap="close">
  125. <u-icon name="close" color="#333333" size="28"></u-icon>
  126. </view>
  127. </view>
  128. <u-button @click="inputConfirm" plain :ripple="true" ripple-bg-color="rgba(25, 190, 107,.4)">确认</u-button>
  129. </view>
  130. </u-keyboard>
  131. <u-select @confirm="shopConfirm" v-model="shopShow" value-name="id" label-name="name" :list="shopList"></u-select>
  132. </view>
  133. </template>
  134. <script>
  135. export default {
  136. data() {
  137. return {
  138. show:false,
  139. money:"0",
  140. scanNotify:{scan: false,scanMessage:'扫描错误,请稍后重试!' },
  141. //下拉选择商铺
  142. shopShow:false,
  143. //我的商铺列表
  144. shopList:[],
  145. //选中的商铺id
  146. shopId:'',
  147. //选中的商铺labe
  148. shopLable:'',
  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/publish.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/list.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. methods: {
  218. logout(){
  219. this.$dialog.showModal('确定要退出吗?').then(res=>{
  220. uni.clearStorage()
  221. uni.reLaunch({
  222. url:"../login/account-login"
  223. })
  224. })
  225. },
  226. async init(){
  227. let phone=this.$cache.get('phone')
  228. let params={
  229. personTel:phone,
  230. auditStatus:1 //审核通过
  231. }
  232. let res=await this.$api.shop.list(params)
  233. this.shopList=res.data.records
  234. let item=this.shopList[0]
  235. this.shopId = item.id
  236. this.shopLable = item.name
  237. this.mallId=item.mallId
  238. this.cacheSelectedShop()
  239. //获取统计数据
  240. this.getStatistic()
  241. },
  242. getStatistic(){
  243. this.$api.shop.statistic(this.shopId).then(res=>{
  244. this.statistic=res.data
  245. })
  246. },
  247. cacheSelectedShop(item){
  248. let selectedShop={
  249. id:this.shopId,
  250. label:this.shopLable
  251. }
  252. this.$cache.put("selectedShop",selectedShop)
  253. this.$u.vuex('vuex_shopId',this.shopId)
  254. this.$u.vuex('vuex_mallId',this.mallId)
  255. },
  256. shopConfirm(e){
  257. this.mallId=e[0].value
  258. this.mallLable=e[0].label
  259. this.cacheSelectedShop()
  260. },
  261. operate(index){
  262. if (index==0) {
  263. this.show=true
  264. }else if (index==1) {
  265. this.$jump('/pages/checkstand/pay-qrcode')
  266. }else if (index==2) {
  267. this.$jump('/pages/card/card')
  268. }
  269. },
  270. //扫描二维码
  271. onChange(val){
  272. if (this.money=='0' && val!='.') {
  273. this.money=val
  274. return
  275. }
  276. console.log(typeof this.money);
  277. console.log(typeof val);
  278. this.money += val.toString()
  279. },
  280. onBackspace(e){
  281. if(this.money.length>0 &&this.money!='0'){
  282. this.money = this.money.substring(0,this.money.length-1);
  283. }else{
  284. this.money='0'
  285. }
  286. },
  287. inputConfirm(){
  288. if (this.$isEmpty(this.money)) {
  289. this.$u.toast('请输入收款金额')
  290. return
  291. }
  292. if (!this.$verify.isMoney(this.money)) {
  293. this.$u.toast('请输入正确的收款金额')
  294. return
  295. }
  296. this.show=false
  297. this.scanCode()
  298. },
  299. close(){
  300. this.money='0'
  301. this.show=false
  302. },
  303. scanCode(){
  304. const _this = this;
  305. uni.scanCode({
  306. success: function (res) {
  307. _this.payBefore(res.result)
  308. },
  309. fail: (res) => {
  310. if(res.errMsg!='scanCode:fail cancel'){
  311. _this.scanNotify = {scan: true,scanMessage: res.errMsg};
  312. }
  313. }
  314. });
  315. },
  316. async payBefore(secret){
  317. let expireTime=this.$dateTime.getExpireTime(5)
  318. let params={
  319. shopId:this.vuex_shopId,
  320. money:this.money,
  321. billsTitle:'用户支付',
  322. expireTime,
  323. appId:this.$global.wxParams.clientAppId,
  324. secret,
  325. type:2
  326. }
  327. let resp=await this.$api.shop.payBefore(params)
  328. console.log(resp);
  329. }
  330. }
  331. }
  332. </script>
  333. <style lang="scss" scoped>
  334. .cu-list.grid>.cu-item .cu-tag {
  335. right: auto;
  336. left: 54%;
  337. margin-left: 20rpx;
  338. }
  339. .title {
  340. display: flex;
  341. .icon {
  342. background-color: #FFFFFF;
  343. border-radius: 50%;
  344. display: flex;
  345. justify-content: center;
  346. align-items: center;
  347. width: 50rpx;
  348. height: 50rpx;
  349. image {
  350. width: 36rpx;
  351. height: 36rpx;
  352. }
  353. }
  354. text {
  355. font-weight: 800;
  356. font-size: 32rpx;
  357. color: #303030;
  358. }
  359. }
  360. .top-menu {
  361. border-radius: 20rpx;
  362. margin-top: 20rpx;
  363. background-image: linear-gradient(to right, #FBA33D, #FF8D32);
  364. }
  365. .menu-list {
  366. display: flex;
  367. justify-content: space-between;
  368. padding-top: 20rpx;
  369. .menu {
  370. width: 48.8%;
  371. color: #FFFFFF;
  372. display: flex;
  373. flex-direction: column;
  374. align-items: center;
  375. border-radius: 14rpx;
  376. padding: 30rpx 20rpx;
  377. .menu-top {
  378. display: flex;
  379. image {
  380. width: 70rpx;
  381. height: 70rpx;
  382. }
  383. }
  384. .menu-bottom {
  385. padding-top: 20rpx;
  386. font-size: 30rpx;
  387. display: flex;
  388. justify-content: space-around;
  389. width: 100%;
  390. view {
  391. display: flex;
  392. flex-direction: column;
  393. text-align: center;
  394. text:first-child {
  395. margin-bottom: 10rpx;
  396. font-size: 26rpx;
  397. color: #E0E2F6;
  398. }
  399. }
  400. }
  401. }
  402. .menu1 {
  403. background-color: #5C6186;
  404. }
  405. .menu2 {
  406. background-color: #E19D5B;
  407. }
  408. }
  409. .market {
  410. margin-top: 20rpx;
  411. border-radius: 20rpx;
  412. background-color: #FFFFFF;
  413. padding: 30rpx 50rpx 20rpx;
  414. .title {
  415. font-weight: 800;
  416. }
  417. .icon {
  418. width: 120rpx;
  419. height: 120rpx;
  420. display: flex;
  421. justify-content: center;
  422. align-items: center;
  423. border-radius: 20rpx;
  424. padding: 20rpx;
  425. image {
  426. width: 60rpx;
  427. height: 60rpx;
  428. }
  429. }
  430. }
  431. .system {
  432. margin-top: 20rpx;
  433. border-radius: 20rpx;
  434. background-color: #FFFFFF;
  435. padding: 30rpx 50rpx 20rpx;
  436. .title {
  437. font-weight: 800;
  438. }
  439. }
  440. .btn{
  441. margin-right: -30rpx;
  442. display: flex;
  443. .image{
  444. display: flex;
  445. justify-content: center;
  446. align-items: center;
  447. border-radius: 50%;
  448. background-color: #FFFFFF;
  449. padding: 8rpx;
  450. image{
  451. width: 20rpx;
  452. height: 20rpx;
  453. }
  454. }
  455. color: #FFFFFF;
  456. border-radius: 50rpx 0 0 50rpx;
  457. padding:8rpx 10rpx 8rpx 35rpx;
  458. background-image: linear-gradient(to right,#FFD67B,#F99200);
  459. }
  460. .money{
  461. font-size: 80rpx;
  462. color: $u-type-warning;
  463. position: relative;
  464. .close{
  465. position: absolute;
  466. top: 20rpx;
  467. right: 20rpx;
  468. line-height: 28rpx;
  469. font-size: 28rpx;
  470. }
  471. }
  472. </style>