appointmentD.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <view class="center">
  3. <view class="card">
  4. <view class="bor">
  5. <view class="bor-top flex">
  6. <view class="user flex">
  7. <view class="avtor"><image class="portrait" :src="userInfo.avatar || '/static/img/missing-face.png'"></image></view>
  8. <view class="name-box">
  9. <view class="name clamp">{{ userInfo.phone || userInfo.email || '游客' }}</view>
  10. <template v-if="list.my">
  11. <view class="tip" style="margin-top: 10rpx;" v-if="list.my.is_forever=1">永久开通</view>
  12. <view class="tip" style="margin-top: 10rpx;" v-else>距离到期还有{{ list.js }}天</view>
  13. </template>
  14. <view class="tip" style="margin-top: 10rpx;" v-else>尚未开通</view>
  15. </view>
  16. </view>
  17. <view class="type">{{ list.my ? '已开通' : '未开通' }}</view>
  18. </view>
  19. <view class="ling-box flex">
  20. <view class="ling-left"><view class="ling-title">开启自动拼团</view></view>
  21. <view class="flex">
  22. <u-switch :loading="checkedLoding" v-model="checkedAuto" active-color="#FED591" active-value="1" inactive-value="0" @change="changeTye"></u-switch>
  23. <text style="margin-left: -40rpx; z-index: 0;font-weight: bold;font-size: 30rpx;font-family: PingFang SC;font-weight: bold;color: #333333;">关</text>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="box">
  29. <view class="top flex">
  30. <view class="bg"><image src=".../../static/img/index4.png" mode=""></image></view>
  31. <view class="title">{{ list.name }}</view>
  32. </view>
  33. <view class="main-bg"><image src="../../static/img/auto.png" mode=""></image></view>
  34. <view class="font">
  35. 预约消耗:
  36. <span class="money">{{ list.money * 1 }}{{ list.money_type }}</span>
  37. </view>
  38. <view class="font" style="margin-top: 10rpx;">
  39. 预约时间:
  40. <span class="time">{{ list.is_forever == 1 ? '永久' : list.valid_date + '天' }}</span>
  41. </view>
  42. <view class="font" style="margin-top: 10rpx;">
  43. 适用拼购:
  44. <span class="time">{{ list.lalaname }}</span>
  45. </view>
  46. <view class="btn" @click="buy()">立即购买</view>
  47. </view>
  48. <u-popup v-model="show1" mode="center" width="548rpx" border-radius="14">
  49. <view class="psw-wrapper">
  50. <view class="psw-title">请输入支付密码</view>
  51. <input type="password" v-model="password" class="psw-ipt" />
  52. <view class="psw-btn">
  53. <text @click="cancel">取消</text>
  54. <text class="psw-qd" @click="pswQd">确定</text>
  55. </view>
  56. </view>
  57. </u-popup>
  58. </view>
  59. </template>
  60. <script>
  61. import { mapState, mapMutations } from 'vuex';
  62. import { autoDetails, buyauto, openclose } from '@/api/product.js';
  63. export default {
  64. data() {
  65. return {
  66. id: '',
  67. list: '',
  68. show1: false,
  69. password: '',
  70. autoid: '',
  71. checkedAuto: false, //是否开启自动领红包
  72. checkedLoding: false //请求自动加载设置保存中
  73. };
  74. },
  75. onLoad(option) {
  76. this.id = option.id;
  77. this.loadData();
  78. },
  79. computed: {
  80. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  81. },
  82. methods: {
  83. async loadData() {
  84. const obj = this;
  85. uni.showLoading({
  86. title: '加载中',
  87. mask: true
  88. });
  89. autoDetails({}, this.id).then(({ data }) => {
  90. obj.list = data;
  91. obj.list.lalaname = '';
  92. if (data.my) {
  93. obj.autoid = data.my.id;
  94. let time = Date.parse(new Date()).toString(); //获取到毫秒的时间戳,精确到毫秒
  95. time = (time.substr(0, 10))*1;
  96. let date = data.my.valid_time - time;
  97. console.log(date,data.my.valid_time,time)
  98. obj.list.js = (date / (3600 * 24)).toFixed(0);
  99. if (date % (3600 * 24) != 0) {
  100. obj.list.js = 1 + obj.list.js * 1;
  101. }
  102. if (data.my.status == 1) {
  103. obj.checkedAuto = true;
  104. }
  105. }
  106. for (let i = 0; i < data.lalas.length; i++) {
  107. if (i == 0) {
  108. obj.list.lalaname += data.lalas[i].name;
  109. } else {
  110. obj.list.lalaname += ',' + data.lalas[i].name;
  111. }
  112. }
  113. console.log(obj.list);
  114. uni.hideLoading();
  115. });
  116. },
  117. buy() {
  118. this.show1 = true;
  119. },
  120. cancel() {
  121. this.password = '';
  122. this.show1 = false;
  123. },
  124. pswQd() {
  125. const obj = this;
  126. buyauto(
  127. {
  128. trade_psw: this.password
  129. },
  130. this.id
  131. )
  132. .then(e => {
  133. this.password = '';
  134. this.show1 = false;
  135. this.$api.msg('购买自动拼团成功');
  136. })
  137. .catch(e => {
  138. this.password = '';
  139. this.show1 = false;
  140. console.log(e);
  141. });
  142. },
  143. changeTye(e) {
  144. if (this.checkedLoding) {
  145. return;
  146. }
  147. this.checkedLoding = true;
  148. if (this.autoid == '') {
  149. this.$api.msg('还未够买该服务或该服务已过期');
  150. this.checkedLoding = false;
  151. this.checkedAuto = false;
  152. } else {
  153. openclose({}, this.autoid)
  154. .then(e => {
  155. uni.showToast({
  156. title: '设置成功!'
  157. });
  158. this.checkedLoding = false;
  159. // this.checkedAuto = !this.checkedAuto
  160. })
  161. .catch(e => {
  162. console.log(e);
  163. this.checkedLoding = false;
  164. });
  165. }
  166. }
  167. }
  168. };
  169. </script>
  170. <style lang="scss">
  171. .card {
  172. padding: 12rpx;
  173. width: 700rpx;
  174. background: linear-gradient(270deg, #ffeacb 0%, #fed591 100%);
  175. border-radius: 20rpx;
  176. margin: 26rpx auto;
  177. .bor {
  178. border: 1px solid rgba(205, 180, 122, 0.38);
  179. border-radius: 20rpx;
  180. padding: 28rpx 25rpx 39rpx 32rpx;
  181. .bor-top {
  182. justify-content: space-between;
  183. .user {
  184. justify-content: flex-start;
  185. .avtor {
  186. width: 100rpx;
  187. height: 100rpx;
  188. border-radius: 50%;
  189. image {
  190. width: 100%;
  191. height: 100%;
  192. border-radius: 50%;
  193. }
  194. }
  195. .name-box {
  196. margin-left: 22rpx;
  197. .name {
  198. width: 356rpx;
  199. font-size: 32rpx;
  200. font-family: PingFang SC;
  201. font-weight: bold;
  202. color: #333333;
  203. }
  204. .tip {
  205. margin-top: 6rpx;
  206. font-size: 24rpx;
  207. font-family: PingFang SC;
  208. font-weight: 500;
  209. color: #a89575;
  210. }
  211. }
  212. }
  213. .type {
  214. width: 180rpx;
  215. height: 64rpx;
  216. background: rgba(215, 160, 116, 0.29);
  217. border-radius: 32px;
  218. text-align: center;
  219. line-height: 64rpx;
  220. font-size: 32rpx;
  221. font-family: PingFang SC;
  222. font-weight: bold;
  223. color: #6e482b;
  224. opacity: 0.47;
  225. }
  226. }
  227. .ling-box {
  228. margin-top: 60rpx;
  229. .ling-title {
  230. font-size: 30rpx;
  231. font-family: PingFang SC;
  232. font-weight: bold;
  233. color: #644931;
  234. }
  235. }
  236. }
  237. }
  238. .box {
  239. margin: 20rpx auto 0;
  240. width: 690rpx;
  241. padding: 20rpx 20rpx 52rpx 30rpx;
  242. background: #ffffff;
  243. box-shadow: 0px 0px 17rpx 0px rgba(0, 0, 0, 0.05);
  244. border-radius: 20rpx;
  245. .top {
  246. justify-content: flex-start;
  247. align-items: center;
  248. .bg {
  249. width: 48rpx;
  250. height: 46rpx;
  251. image {
  252. width: 100%;
  253. height: 100%;
  254. }
  255. }
  256. .title {
  257. margin-left: 10rpx;
  258. font-size: 34rpx;
  259. font-family: PingFang SC;
  260. font-weight: bold;
  261. color: #0f253a;
  262. }
  263. }
  264. .main-bg {
  265. width: 520rpx;
  266. height: 165rpx;
  267. margin: 55rpx auto 0;
  268. image {
  269. width: 100%;
  270. height: 100%;
  271. }
  272. }
  273. .font {
  274. margin-top: 62rpx;
  275. font-size: 26rpx;
  276. font-family: PingFang SC;
  277. font-weight: 500;
  278. color: #6d7c88;
  279. .money {
  280. font-size: 30rpx;
  281. color: #2e58ff;
  282. }
  283. .time {
  284. color: #0f253a;
  285. }
  286. }
  287. .btn {
  288. width: 558rpx;
  289. height: 80rpx;
  290. background: linear-gradient(0deg, #2e58ff, #32c6ff);
  291. border-radius: 40rpx;
  292. margin: 49rpx auto 0;
  293. text-align: center;
  294. line-height: 80rpx;
  295. font-size: 30rpx;
  296. font-family: PingFang SC;
  297. font-weight: 500;
  298. color: #ffffff;
  299. }
  300. }
  301. .psw-wrapper {
  302. width: 548rpx;
  303. height: 344rpx;
  304. background-color: #ffffff;
  305. .psw-title {
  306. width: 100%;
  307. font-size: 35rpx;
  308. padding: 43rpx 0 49rpx;
  309. text-align: center;
  310. font-weight: 800;
  311. }
  312. .psw-ipt {
  313. display: block;
  314. background-color: #dce3ed;
  315. height: 90rpx;
  316. width: 464rpx;
  317. padding-left: 30rpx;
  318. margin: 0 auto;
  319. font-size: 80rpx;
  320. }
  321. .psw-btn text {
  322. display: inline-block;
  323. text-align: center;
  324. width: 50%;
  325. padding-top: 29rpx;
  326. font-size: 35rpx;
  327. }
  328. .psw-qd {
  329. color: #2e58ff;
  330. }
  331. }
  332. </style>