appointmentD.vue 7.9 KB

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